1. Home
  2. Knowledge Base
  3. WooCommerce Product Add-Ons Ultimate
  4. Product Page
  5. Replace main image with selected image swatch
  1. Home
  2. Knowledge Base
  3. WooCommerce Product Add-Ons Ultimate
  4. Replace main image with selected image swatch

Replace main image with selected image swatch

If you would like to replace your main product image with the selected image swatch, use the following snippet. This will change the main product image when the user selects an image swatch.

Please note that there might limited support for this feature from your theme. You can always test its functionality by switching temporarily to the Storefront theme and rechecking.

<?php
/**
* Replace main image with selected image swatch
*/
function prefix_get_add_on_image_action( $action ) {
return 'replace_hide';
}
add_filter( 'pewc_get_add_on_image_action', 'prefix_get_add_on_image_action' );

This is how to add the snippet.

Was this article helpful?

Related Articles