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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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.