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

Prem Tiwari - - WordPress, WordPress Snippets

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”.


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.

Prem Tiwari

Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer and a blogger by hobby.

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.