Hide “Add to cart” Button When Product Price is Zero

By Prem Tiwari in WordPress, WordPress Snippets. Updated on


Hi friends, Yesterday I got the tutorial request from my blog reader about WooCommerce code hacks to hide Add to cart button when the product price is zero.

For the better understanding here is the complete question “How to hide “Add to cart” button when the product price is Zero”.

wordpress-hacks

Open functions.php file from current activated theme folder and add the bellow code at the end of the file and save it. It will automatically hide the Add to Cart button for all products which price is zero or not entered during product creation time.

Over to You

Do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.

Sharing is caring!


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.

You might also like:

Tags: , , , , , , , ,

1 thought on “Hide “Add to cart” Button When Product Price is Zero”

  1. function remove_add_to_cart_option( $purchasable, $product ){
    if( $product->get_price() == 0 )
    $purchasable = false;
    return $purchasable;
    }
    add_filter( ‘woocommerce_is_purchasable’, ‘remove_add_to_cart_option’, 10, 2 );

    Your rendered HTML messes up the ->

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.