Hi Olivier,
Thanks for reaching out to us. Please add the following code using Code Snippets plugin:
add_action('woo_variation_swatches_pro_archive_page_loaded', function($wvs_pro){
remove_action('woocommerce_init', array( $wvs_pro, 'enable_swatches' ), 1);
add_action('woocommerce_after_shop_loop_item_title', array( $wvs_pro, 'after_shop_loop_item' ), 9);
}, 10, 1);
It will remove the default swatches from the archive page. Then you have no need to add your code, remove your code. Just use the provided code to display swatches, it will display where you have added it using the shortcode.
Note: the above code will not work inside your theme’s functions.php. So, you have to use the Code Snippets plugin. Because the theme code loads first and the snippet will run at the beginning of the site load though the swatches plugin is not loaded yet.
Thank You
different hook for the archive product
Olivier Mandits
I want to use the shortcode to apply the variations on my product archive page because the hooks that are in the plugin do not work for me. But for the shortcode to work I have to activate the enable on archive product option on the plugin, which displays it twice. Could you tell me how to do it please ?
i want to use the hook woocommerce_after_shop_loop_item_title
this is my function for the shortcode :
function add_variation_archive() {
echo do_shortcode(‘[wvs_show_archive_variation]’);
}
add_action(‘woocommerce_after_shop_loop_item_title’, ‘add_variation_archive’);