Are free products cluttering your WooCommerce store? Or are they so many, that you have no intention of manually setting them to “catalog visibility: hidden” one by one and need a proper shortcut?
Well, this guide will walk you through effective methods to conceal them, enhancing your store’s overall aesthetic and user experience.
Discover how to strategically hide $0 products from the shop / category / archive pages using WooCommerce custom code or dedicated plugins – enjoy!
PHP Snippet: Hide $0 Price Products @ WooCommerce Shop / Category / Tag / Search / Archive Pages
/**
* @snippet Remove Free Products @ Woo Shop
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 9
* @community https://businessbloomer.com/club/
*/
add_action( 'woocommerce_product_query', 'bbloomer_hide_products_0_price', 9999, 2 );
function bbloomer_hide_products_0_price( $q, $query ) {
if ( is_admin() ) return;
$meta_query = $q->get( 'meta_query');
$meta_query[] = array(
'key' => '_regular_price',
'value' => 0,
'compare' => '>',
);
$q->set( 'meta_query', $meta_query );
}