'WooCommerce - Automatically reset variations after product add to cart
my product has two variation attributes. The variations are different combinations of the attributes, but not all combinations are available. Some customers want to order different variations of the same product. Currently, they always have to click on the “clear” button in the product page, so they can start choosing again.
I have currently no AJAX active, the page is reloading after pressing “Add to basket” but the selected variation in the product page still stays active.
Is there a possibility to automatically clear the variation attributes after the product was added to the cart so my default value “choose an option” is shown again, and the customer can choose the next variation?
I didn’t find any easy solutions for that, so I thought about a code snippet as a possible solution with calling “woocommerce_reset_variations_link” after the successful “add to cart”, but unfortunately I’m no programmer. If that solution would be feasible, could someone please provide the correct code snippet?
Thank you very much.
Solution 1:[1]
jQuery solution where after reload will click on clear link.
(function ($) {
$( document ).ready(function(){
setTimeout(function() {
$('.reset_variations').trigger('click');
},10);
});
})(jQuery);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Martin Mirchev |
