0

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.

1 Answers1

0

jQuery solution where after reload will click on clear link.

(function ($) {
    $( document ).ready(function(){
        setTimeout(function() {
            $('.reset_variations').trigger('click');
        },10);
    });
})(jQuery);
Snuffy
  • 1,723
  • 1
  • 5
  • 9
  • Thanks for the Answer @martin-mirchev I'm also using some custom fields which is not clear by clicking on clear. How can i clear those fields. – Varun Kumar Apr 21 '22 at 21:02
  • That depends on your fields but you can see some examples - https://stackoverflow.com/questions/1857781/best-way-to-unselect-a-select-in-jquery – Snuffy Apr 22 '22 at 10:21