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.
1 2 3 4 5 6 |
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 ); |
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.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: woocommerce hacks, woocommerce tips, woocommerce trick, woocommerce tutorials, wordpress tutorial, wordpress tutorial for beginner, wordpress tutorials, wordpress tutorials for beginners, wordpress woocommerce tutorial