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

Disabling shop/archive swatches for certain products

Hello, for some products it does not make sense to show variation swatches on the shop/archive page. For example when a product has one color but various sizes. In such a case I don’t need to show any swatches. How can I disable that without disabling swatches for ALL products? This would be an important feature.

Rezwan Shiblu

Hi there,

Thanks for reaching out to us.

Sorry, the feature is not currently available.

You can send a feature request here- https://storepress.fider.io/

and let others users vote for it and follow the development of the feature if it’s accepted by the development team.

Thank you.

Hakik Zaman

Hi Rainer,

Add the following snippet using Code Snippets plugin or put the below code inside your child theme’s functions.php:

add_filter('disable_woo_variation_swatches_archive_product', function($default, $product){
$target = [14]; //Insert the product id’s inside the target. For Example: [14,45]

if( in_array( $product->get_ID(), $target ) ){
return true;
}
return $default;
}, 10, 1);

Note: Insert the product ID inside the $target variable as instructed inside the code block.

Cheers!

Thanks for the snippet but I have too many products and would need to enter also the IDs for all translations. Maybe I can make it work with a custom field value (like a checkbox in the product settings) instead of an ID. Or I hope that this will be integrated at some point.

I tried this, maybe you have a hint to make it work 🙂

 

function woo_swatches() {
if ( get_field( ‘custom_field_hide_swatches’ ) ) {
add_filter( ‘disable_woo_variation_swatches_archive_product’, ‘__return_true’ );
}
}
add_action( ‘woocommerce_after_shop_loop_item’, ‘woo_swatches’ );

 

Hakik Zaman

Hi Rainer,

I am afraid it is a custom request. I don’t know the field you are using an array or something else.

I have already given a hint. If you need any further modification, please hire a developer.

Thank You

Fair enough. But the code you posted seems not to work unfortunately.

Critical error caused. This is the debug information. Are you sure your code is correct?

 

#8 /home/wp/disk/wordpress_staging/wp-includ in /home/wp/disk/wordpress_staging/wp-content/themes/storefront-child/functions.php on line 33

#7 /home/wp/disk/wordpress_staging/wp-includes/class-wp-hook.php(308): wp_enqueue_scripts()

#6 /home/wp/disk/wordpress_staging/wp-includes/script-loader.php(2180): do_action()

#5 /home/wp/disk/wordpress_staging/wp-includes/plugin.php(517): WP_Hook->do_action()

#4 /home/wp/disk/wordpress_staging/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()

#3 /home/wp/disk/wordpress_staging/wp-includes/class-wp-hook.php(308): Woo_Variation_Swatches_Pro_Archive_Page->enqueue_scripts()

#2 /home/wp/disk/wordpress_staging/wp-content/plugins/woo-variation-swatches-pro/includes/class-woo-variation-swatches-pro-archive-page.php(408): apply_filters()

#1 /home/wp/disk/wordpress_staging/wp-includes/plugin.php(205): WP_Hook->apply_filters()

#0 /home/wp/disk/wordpress_staging/wp-includes/class-wp-hook.php(310): {closure}()

Hakik Zaman

Hi Rainer,

Can you please give us temporary admin access to your staging site? We’ll try to investigate the issue for you.

You can add new users by going to Users > Add New setting the user and password for us, set the role to admin and set the info here.

And add your site URL, login username, and password in the site login area. Follow this guideline: https://www.useloom.com/share/27c1f2ac633c4060b2da883d946107d7

Hope to hear from you soon!