fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

The product image does not change when click the variations after AJAX requests

Brain Shi

Hi

Can you please have a look at this page? I am a developer who help my client build his website. I wrote an AJAX filter on the shop page and made it work with some custom post mates.

My question is once the AJAX request is done then refresh the product list. The variations swatches seems not working anymore. the product thumbnail doesnot change after I click the variations swatches.

By checking this document https://getwooplugins.com/documentation/woocommerce-variation-swatches/#infinite-scroll-or-ajax-load-more
I have added the code snippet after my AJAX respone is recieved:

$(‘.variations_form’).each(function(){
$(this).wc_variation_form();
});

But it still does not work.

Can you please tell me why and anything I missed?

Thanks!

Brain Shi

I think I have found the solution.

The response product list does not has the class ‘wvs-attachment-image’ on the thumbnail images. So I have add a line :

$( ‘.size-woocommerce_thumbnail’ ).addClass(‘wvs-attachment-image’)

Then it is working fine. And I tried to remove the lines:

$(‘.variations_form’).each(function(){
$(this).wc_variation_form();
});

it still works fine. I guess you need to update your document for developers to note them add back the class ‘wvs-attachment-image’ because sometime other plugins do not retrieve this class.

Hakik Zaman

Hi Brain,

Thanks for reaching out to us. Really glad that you have resolved your issue.

I guess you need to update your document for developers to note them add back the class ‘wvs-attachment-image’ because sometime other plugins do not retrieve this class.

I will inform this matter to my team. Hopefully, they will look into it.

We really get excited & honored when you use our plugin on your site.

If you love our plugin, could you leave your valuable review here: https://wordpress.org/support/plugin/woo-variation-swatches/reviews/?filter=5

Your rating keeps us inspired.

Thank You