woocommercehideproductzero

Can we hide the woocommerce product with price 0 or no price?


Everyone: I wanted to ask, if there is a way (custom coding or plugin) to hide the product which have no price or the price is 0?


Solution

  • //Put this code in functions.php file
    
    add_action( 'woocommerce_product_query', 'themelocation_product_query' );
    function themelocation_product_query( $q ){
    $meta_query = $q->get( 'meta_query' );
        $meta_query[] = array(
                    'key'       => '_price',
                    'value'     => 0,
                    'compare'   => '>'
                );
    $q->set( 'meta_query', $meta_query );
    }