Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionI created a custom button to add products to cart and I'm using this link: ;product_id=91&variation_id=93&attribute_pa_typographie=oscine-bold&attribute_pa_contour=sans&attribute_pa_departement=15&attribute_pa_percage=avec&plaque=RR-158-RR&bavette=&quantity=1
It's the cart page. Two days ago, this link was working and adding products to cart but it's not anymore.
I tried deactivating all plugins (but WC obviously), testing with a non variable product, sending request via GET and POST, checking and non-checking all ajax buttons in settings but nothing will do.
I checked the logs which didn't help either.
Does someone have an idea what to do? Clicking this link should add product to the cart.
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionI created a custom button to add products to cart and I'm using this link: http://signaturecarbone.s23528.liner7.atester.fr/panier?add_to_cart=91&product_id=91&variation_id=93&attribute_pa_typographie=oscine-bold&attribute_pa_contour=sans&attribute_pa_departement=15&attribute_pa_percage=avec&plaque=RR-158-RR&bavette=&quantity=1
It's the cart page. Two days ago, this link was working and adding products to cart but it's not anymore.
I tried deactivating all plugins (but WC obviously), testing with a non variable product, sending request via GET and POST, checking and non-checking all ajax buttons in settings but nothing will do.
I checked the logs which didn't help either.
Does someone have an idea what to do? Clicking this link should add product to the cart.
Share Improve this question asked Jan 4, 2018 at 23:30 SkouaSkoua 1336 bronze badges 4- Has anything has been updated recently? Also, have you tried incognito-mode? it could be something cached. – admcfajn Commented Jan 4, 2018 at 23:35
- Well I'm currently working on the website so I changed a lot of stuff. Was is incognito mode? :p – Skoua Commented Jan 4, 2018 at 23:36
- 1 It might be a deprecated feature and you'd need to rollback the plugin. I'd see if restoring the older version of woocommerce helps. incognito mode or private browsing can help when testing for cached stuff, or if you need to view the site as a non-logged in user without logging out & back in again support.google/chrome/answer/… – admcfajn Commented Jan 4, 2018 at 23:43
- Alright yes of course. I just rolleback to WC 3.1.2 for a try but it didn't help. I did try to visit without cache or being logged in but nothing! – Skoua Commented Jan 4, 2018 at 23:51
1 Answer
Reset to default 1So I ended up making a workaround because I still have no clue what's happening. I changed the url to point to the product page and I'm using ol'good PHP to get the values and add the product with WooCommerce API. Here's my code:
if(isset($_GET['order']) && $_GET['order'] == 'true') {
$typo = isset($_GET['attribute_pa_typographie']) ? $_GET['attribute_pa_typographie'] : '';
$contour = isset($_GET['attribute_pa_contour']) ? $_GET['attribute_pa_contour'] : '';
$departement = isset($_GET['attribute_pa_departement']) ? $_GET['attribute_pa_departement'] : '';
$percage = isset($_GET['attribute_pa_percage']) ? $_GET['attribute_pa_percage'] : '';
$plaque = isset($_GET['plaque']) ? $_POST['plaque'] : '';
$bavette = isset($_GET['bavette']) ? $_POST['bavette'] : '';
$quantity = isset($_POST['quantity']) && is_numeric($_POST['quantity']) ? (int)$_POST['quantity'] : 1;
$attrs = [
'attribute_pa_typographie' => $typo,
'attribute_pa_contour' => $contour,
'attribute_pa_departement' => $departement,
'attribute_pa_percage' => $percage,
'plaque' => $plaque,
'bavette' => $bavette
];
WC()->cart->add_to_cart($productID, $quantity, $variationID, $attrs);
wp_redirect('/panier');
exit;
}
Not very fancy but it works. If someone has a better idea, I'm all ears!