How to Hide WooCommerce Product If Price Is Zero?πŸŽ‰πŸŽ‰πŸŽπŸŽ

How to Hide WooCommerce Product If Price Is Zero?πŸŽ‰πŸŽ‰πŸŽπŸŽ

Wanna to Hide Products, When Price is Zero ?

When you want to give product as freebies for your customers, like on Christmas and you don’t want to spend money for the customer freebies or you might be a developer then this solution is for you😊😊😊.

If you left the price empty then,Woocommerce will disable the add to cart button.Beside that ,you dont wanna display price product rather you wanna hide the price and replace with message like ”This Product is free”.

 

 

  • Go to Dashboard -> Appearance -> Editor
  • Click on functions.php
  • Add the following Code in the end of the functions file
    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 );
    }

Ashok kuikel

Hi, I am Ashok Kuikel, WordPress Developer for WordPress Community. While Cloud Computing Associate and Alibaba MVP and ACA for Cloud Professional. You can follow me on Social Media, GitHub, and via my Blog Channels.

Leave a Reply

Your email address will not be published. Required fields are marked *