Hello! I’m following up on a question that was already asked here. BUT, I can’t seem to figure out a way to disable the featured image replacement, as described here. Is there a hook or js that I can implement to prevent it from doing so?
To see what I’m talking about, you can visit this product:
http://us129.siteground.us/~liecolle/product/flower-embroidery-off-the_shoulder-top/
Keep an eye on the thumbnail images on the left as you click one of the variation buttons. See how the button swaps out the “woocommerce_gallery_thumbnail” image size for the “woocommerce_thumbnail” image size?
Is there a way to prevent the variation switch from doing this?
After a lot of work on this… I finally figured it out. I had to make a change to a core plugin file.
In the file: /woo-variations-style-buttons/assets/add-to-cart-variation.js
From Lines 489 to 538
You want to delete or comment out the following Javascript function:
/** * Sets product images for the chosen variation */ $.fn.wc_variations_image_update = function( variation ) { var $form = this, $product = $form.closest( '.product' ), $product_gallery = $product.find( '.images' ), $gallery_img = $product.find( '.flex-control-nav li:eq(0) img' ), $product_img_wrap = $product_gallery.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' ).eq( 0 ), $product_img = $product_img_wrap.find( '.wp-post-image' ), $product_link = $product_img_wrap.find( 'a' ).eq( 0 ); if ( variation && variation.image && variation.image.src && variation.image.src.length > 1 ) { $product_img.wc_set_variation_attr( 'src', variation.image.src ); $product_img.wc_set_variation_attr( 'height', variation.image.src_h ); $product_img.wc_set_variation_attr( 'width', variation.image.src_w ); $product_img.wc_set_variation_attr( 'srcset', variation.image.srcset ); $product_img.wc_set_variation_attr( 'sizes', variation.image.sizes ); $product_img.wc_set_variation_attr( 'title', variation.image.title ); $product_img.wc_set_variation_attr( 'alt', variation.image.alt ); $product_img.wc_set_variation_attr( 'data-src', variation.image.full_src ); $product_img.wc_set_variation_attr( 'data-large_image', variation.image.full_src ); $product_img.wc_set_variation_attr( 'data-large_image_width', variation.image.full_src_w ); $product_img.wc_set_variation_attr( 'data-large_image_height', variation.image.full_src_h ); $product_img_wrap.wc_set_variation_attr( 'data-thumb', variation.image.src ); $gallery_img.wc_set_variation_attr( 'src', variation.image.thumb_src ); $product_link.wc_set_variation_attr( 'href', variation.image.full_src ); } else { $product_img.wc_reset_variation_attr( 'src' ); $product_img.wc_reset_variation_attr( 'width' ); $product_img.wc_reset_variation_attr( 'height' ); $product_img.wc_reset_variation_attr( 'srcset' ); $product_img.wc_reset_variation_attr( 'sizes' ); $product_img.wc_reset_variation_attr( 'title' ); $product_img.wc_reset_variation_attr( 'alt' ); $product_img.wc_reset_variation_attr( 'data-src' ); $product_img.wc_reset_variation_attr( 'data-large_image' ); $product_img.wc_reset_variation_attr( 'data-large_image_width' ); $product_img.wc_reset_variation_attr( 'data-large_image_height' ); $product_img_wrap.wc_reset_variation_attr( 'data-thumb' ); $gallery_img.wc_reset_variation_attr( 'src' ); $product_link.wc_reset_variation_attr( 'href' ); } window.setTimeout( function() { $product_gallery.trigger( 'woocommerce_gallery_init_zoom' ); $form.wc_maybe_trigger_slide_position_reset( variation ); $( window ).trigger( 'resize' ); }, 10 ); };
Comment out or delete ALL of the above. That will stop it from updating the variation image.
I’ll follow up in the other thread as well, in case others are looking for an answer. It certainly isn’t the most elegant… But at least it gets the job done.
Hi
Everything will be as default woocomerce . please check default woocomerce so you will understand rest issue …
Thanks