Andy Tran

Hide the Product Price When Price Zero

by | 30 Aug, 2021 | WooCommerce, Wordpress | 0 comments

Hide the Product Price When Price Zero

By default woo-commerce displays product price in shop page and single product detail page but what to do if the product price is zero. Price is one of the most important aspects of any eCommerce store. It’s one of the main elements that customers consider when buying a product or service. It’s not looking good on your shop page when the product price is zero so it’s better to hide the price of a Product when it’s zero on the product detail page or shop page.

Woocommerce Product - Hide Price When Price is Zero

Woocommerce Product – Hide Price When Price is Zero

Write the following code in your functions.php file to Remove Additional CSS from the WordPress Customizer.

How to Hide the Product Price When Price Zero?

It is not hard to customize the WooCommerce shop page, product page, category layout, etc. to hide prices in the WooCommerce store. The easiest way is using the plugin. But if you need more flexibility, you will most likely need to apply code.
Hiding prices in WooCommerce gives you more control over who has access to pricing information on your site.

    • Login to your WordPress Admin Dashboard.
    • Now from the left sidebar go to Appearance -> Theme Editor.
    • Go to functions.php file and write below code.

function hide_product_price_display( $price ) {
    $clear = trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($price))))));
    if($clear == "0 00"){
      return '';
    return $price;
add_filter( 'woocommerce_get_price_html', 'hide_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'hide_product_price_display' );

Hide WooCommerce Product Price zero


After adding this code block, you will successfully hide your woocommerce Product Price When Price is Zero.

To Continue Learning, you can refer our blogpost Create Custom Post Type – Without Plugin

Thank you for taking the time to explore our blog. We trust that you have discovered valuable insights into our ideas and processes. Are you in search of IT Outsourcing Services for your company ? Erudite Works Private Limited stands out as a prominent player in the IT outsourcing services sector, placing a strong emphasis on delivering outstanding outcomes. Our team of experts is wholeheartedly dedicated to comprehending the distinct needs and challenges faced by our clients, enabling us to offer customized solutions that foster significant business expansion. Backed by a proven track record of successful projects, we are steadfast in our commitment to aiding clients in attaining their objectives and maintaining a competitive advantage in the swiftly evolving digital landscape.

To delve deeper into our services, please don’t hesitate to get in touch with us. Contact Us.

Share this article...


Submit a Comment

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

The reCAPTCHA verification period has expired. Please reload the page.