Reputation: 151
Is there a way to disable image change on variation select of a variable product?
I know that you can simple remove the image from variation but in my case this isn't an option because i need the variation images.
Any help is appreciated.
Upvotes: 2
Views: 2117
Reputation: 111
Commenting out anything in WooCommerce plugin files isn't the most rational solution, because whenever WooCommerce pushes an update that changes that file, your changes are lost.
WooCommerce uses wc_variations_image_update method nowadays (11/2023). Hijacking the method removes the functionality of image change on variation selectiton.
jQuery(($) => {
$.fn.wc_variations_image_update = () => {
//Do nothing
}
});
Upvotes: 1
Reputation: 151
I'm posting a solution, not the perfect one, but is something.
In WooCommerce/assets/js/frontend/add-to-cart-variation.min file you can comment i.$form.wc_variations_image_update(a)
and this will make variation image update on selection.
Upvotes: 3