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

disable swatches on archive pages in mobile only

lev knyazev

when the option of “Show swatches on archive / shop page.” is enabled

mobile/tablet users experience very long load time.

how can we disable this feature only on mobile and tablet?

thanks in advance!

Hakik Zaman

Hi lev,

Thanks for reaching out to us. Please add a plugin called Code Snippets. Then add a snippet by copying the following snippet:
add_action('woo_variation_swatches_pro_archive_page_loaded', function($wvs_pro){
if( wp_is_mobile() ){
remove_action('woocommerce_init', array( $wvs_pro, 'enable_swatches' ), 1);
}
}, 10, 1);
Please let me know whether you have wanted this solution or not.

Thank You

lev knyazev

it doesn’t work, navigating to product category page still all products have the swatches

Hakik Zaman

Hi lev,

Can you please provide the category page link to check?

Thank You

lev knyazev

sorry, after adding the correct snippet plugin, it is working now, thank you!