Home > WooCommerce > How to Hide the WooCommerce Product Price When Price Zero?

How to Hide the WooCommerce Product Price When Price Zero?

By default woocommerce display the price of products on the shop archive page or single product page but what if your product has zero price and you want to hide the price for that product.

However, if you also want to display the “FREE” text instead of the “$0.00” price then you can simply do that with the help of action hooks.

Because instead of showing the “$0.00” price and showing the “FREE” text look more elegant and also engages the customer.

Let’s see how we can hide the woocommerce product price when the product has zero price.

Hide Price When Price Zero

We will use the woocommerce_get_price_html filter hook to hide the product price if the price is zero and show something instead of “$0.00”.

See the following image showing the “$0.00” price in the default behavior.

Product with price

Now, let’s make a function to customization in price HTML content and check if the product price is zero then don’t show the price text.

Add the following code in your theme’s functions.php file and I would recommend using the child theme so you don’t lose your changes when the theme is updated.

If you don’t have a child theme, you can check our guide on how to create a child theme in WordPress?

When you have added the above code successfully in your theme and saved it, you will see your product price is not showing if the product price has zero. You will see the product like the following image, without the price.

Product with hidden price

But did you notice that the product is not looking good because one of the main elements is not shown to the customer? And customers get confused while buying products.

So it will be good if you show the “FREE” text to customers, so they get attracted to the product by seeing the “FREE” label. So let’s do it.

Display FREE Text When Price Zero

OK. So we will follow the same process to hide the woocommerce product price and display the “FREE” text instead. You just have to add the “FREE” text to the $price variable.

It is not compulsory to add the “FREE” text, it’s all up to you. You can add anything which you want to display when the product has zero price.

Add the following code to your theme’s functions.php file and save it.

After saving the above code, you will see your all product showing the “FREE” text instead of the “$0.00” price. Now you can design it on the front end as you want. See the following image for reference.

Product with FREE text label

That’s it!!!

Photo of author

About Aman Mehra

Hey there! I'm Aman Mehra, a full-stack developer with over six years of hands-on experience in the industry. I've dedicated myself to mastering the ins and outs of PHP, WordPress, ReactJS, NodeJS, and AWS, so you can trust me to handle your web development needs with expertise and finesse. In 2021, I decided to share my knowledge and insights with the world by starting this blog. It's been an incredible journey so far, and I've had the opportunity to learn and grow alongside my readers. Whether you're a seasoned developer or just dipping your toes into the world of web development, I'm here to provide valuable content and solutions to help you succeed. So, stick around, explore the blog, and feel free to reach out if you have any questions or suggestions. Together, let's navigate the exciting world of web development!

Leave a Comment