fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Variation swatch position on the shop page since v2

Andrew Leung

Hi,

I’ve noticed the way the plugin handles the positioning of the swatches to have changed since the plugin updated to v2.

I didn’t like the above/below Add to Cart option, so I used to use this code to move it to above the product title:

add_action( ‘init’, ‘wvs_teepro_theme_support’ );
function wvs_teepro_theme_support()
{
remove_action( ‘woocommerce_after_shop_loop_item’, ‘wvs_pro_archive_variation_template’, 30 );
remove_action( ‘woocommerce_after_shop_loop_item’, ‘wvs_pro_archive_variation_template’, 7 );
add_action( ‘woocommerce_before_shop_loop_item_title’, ‘wvs_pro_archive_variation_template’, 30);
}

However since the update, the plugin no longer uses the wvs_pro_archive_variation_template() function and instead uses array( $this, ‘after_shop_loop_item’ ).

Since this affected my client’s site I needed to make a quick fix so I had to edit the plugin to change the positioning, which isn’t ideal long-term. Is there a better solution?

Hakik Zaman

Hi Andrew,

Thanks for reaching out to us. Please try the below as an example:

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', array( $wvs_pro, 'after_shop_loop_item' ), 9);
}, 10, 1);

Hopefully, it will help.

Thank You