Site icon Experience Wordpress Developer Online – Design Develop and Maintenance Support

Hide WooCommerce Product If Price Is Zero

When the Product is not available OR out of stock then many store owners make the price “0” , It gives an expression to the user that Product is not available. But it’s not look good in your shop page.

So, If you want to hide WooCommerce Product if price is Zero than Add this code in your theme’s functions.php file of your active child theme (or theme).

Save file and Open your shop page you can see the product with price zero is not shown in the products.

add_action( 'woocommerce_product_query', 'hide_zero_price_product' );
function hide_zero_price_product( $q ){
    $meta_query = $q->get( 'meta_query' );
        $meta_query[] = array(
                    'key'       => '_price',
                    'value'     => 0,
                    'compare'   => '>'
                );
    $q->set( 'meta_query', $meta_query );
}
Exit mobile version