WooCommerce: Display “FREE” Instead of $0.00 or Empty Price

In older versions of WooCommerce free prices used to display as “FREE!” and products with empty prices were not publishable. Now they’ve changed this around, but I still believe “FREE” looks much better than “$0.00”. It’s much more enticing, isn’t it?

Well, here’s how you restore the old functionality – as usual it’s as simple as using a PHP filter provided by WooCommerce and overriding the default behavior.

Display “FREE” if WooCommerce Product Price is zero or empty

PHP Snippet: Display “FREE” if WooCommerce Product Price is Zero or Empty – WooCommerce


/**
* @snippet       Display "FREE" if WooCommerce Product Price is Zero or Empty - WooCommerce
* @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
* @sourcecode    https://businessbloomer.com/?p=73147
* @author        Rodolfo Melogli
* @testedwith    WooCommerce 3.5.3
* @donate $9     https://businessbloomer.com/bloomer-armada/
*/

add_filter( 'woocommerce_get_price_html', 'bbloomer_price_free_zero_empty', 100, 2 );
 
function bbloomer_price_free_zero_empty( $price, $product ){

if ( '' === $product->get_price() || 0 == $product->get_price() ) {
    $price = '<span class="woocommerce-Price-amount amount">FREE</span>';
} 

return $price;
}

Where to add this code?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such delicate files - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

Does this snippet still work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

47 thoughts on “WooCommerce: Display “FREE” Instead of $0.00 or Empty Price

  1. wow, it works just now. Thx dude.

    -Dwindi, Indonesia

    1. Great!

  2. Hello,

    I have a question. I am havin a problem to the fact that a free product that is added to cart does not have any tax info since it’s value is 0. Can this be changed ? A function perhaps that for every product that has 0 value the tax is also calculated 0 and not left blank ? I need this for a connection to a crm. Can you quote me on this if possible ? We use woocommerce free gift plugin from codecanyon. Thhank you

    1. Hi Silviu, thanks so much for your comment! Yes, if you’d like to get a quote, feel free to contact me here. Thanks a lot!

  3. This doesn’t work for product variations? If it’s a variation, it shows just FREE, instead FREE – $10. Is there a work around for this?

    1. Hi Jimmy, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  4. Hi there,

    I am looking for a snippet that would also put “FREE” in the order tabel sent by email to customer after placing an order. I have tried this snippet but I still had “0”.

    Any ideas how to achieve what I need?

    1. Hello Piotr, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  5. Hi,

    This breaks the WC RestAPI. The word “Free” in the API response, it doesn’t like it. How can I avoid to change this in the WC API?

    1. Hi Thibault, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  6. Still works in March 2019

    1. Awesome!

  7. Still works very well. Thanks for help man!

    1. Cool!

  8. Great snippet! Is there a way to get this global so in basket, checkout and Woo emails?

    1. Hello Jack, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  9. hi

    how can I show the slashed regular price next to the “free” ?

    Simon

    1. Simon, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  10. WOW, that is awesome! Thanks you
    Is there way to get it work for Woo Product Addons 3.+ plugin?

    Thanks you

    1. Tom, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  11. I just started with WooCommerce today and this was a lifesaver. Thank you.
    A hint to anybody reading comments – You can’t use this with Fields Factory – Price adjustments. It will display your modified price until the Fields Factory plugin then it will revert to $0.00. You have to exclude any price adjustments from your product even if they start as free.

    1. Thank you Mark 🙂

  12. Works perfectly on WordPress Version 4.9.8 and Woocommerce Version 3.4.5.
    Thanks

    1. Great 🙂

  13. This still works well. Thanks!!!

    1. Awesome!

  14. Hi, I have a label free on the product image “one day of art” but the product is not free: where is the problem?

    1. Hey Roberto, thanks so much for your comment! Has that product got a price?

  15. Awesome, thank you! Exactly what I needed. 🙂

    1. Excellent 🙂

  16. I’d suggest that you update this to include the tags that WC wraps its price in. This way you can maintain the same styling you apply to your products that have a price.

    Just include
    $price = ‘FREE’;

    instead of just the FREE text.

    1. Sorry. This is what I wanted to have in my previous comment:

      $price = '<span class="woocommerce-Price-amount amount">FREE</span>';
    2. Ah, excellent, thank you Jack!

  17. Hi there,

    how can I display Free also in the cart or checkout page?

    Thank you for creating this topic.

    Cheers
    Phil

    1. Phil, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  18. Hello,
    Hope you are doing fine.
    Thank you for creating this topic.
    I would like to have the word ” Free ” instead of ” 0$ ” when I enter the price=0
    and ” Coming Soon ” when I leave the price=blank

    How can I do this?

    Kind Regards.
    Rahim

    1. Rahim, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  19. Hi Rodolfo,

    Thanks for this snippet!

    I’ve just tried it on a store that has a variable product. One of the variations is free but the other costs money.

    Without the snippet the price for that product displays as 0.00 – 15.00.

    With the snippet the price shows just as FREE, not displaying the other variation price. You can still see the 15.00 when you select that variation on the dropdown, but I want to be able to see both prices on the shop and the product page i.e. FREE – 15.00.

    Is there a way to amend the code to do that?

    Cheers

    Claire

    1. Hey Claire, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  20. Hi ,
    works fine, I see product FREE but I also see Add to cart button.

    for the product which is FREE , I also want to remove “add to cart button” for this product , as I want to auto add it to cart based on cart total. Can you please provide code for that as well.

    1. Seema, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  21. Hello!

    I´m on woocommerce 3.2.3 and this snippet dont work for me.

    “Parse error: syntax error, unexpected ‘add_filter’ (T_STRING)”

    but thanks!

    1. Hey, thanks for your comment! You must have pasted some extra characters or made a syntax error – try again 🙂

    2. Hello,

      no not really.

      https://abload.de/img/woo_error0suzz.png

      or i dont see whats wrong.

    3. That looks ok to me, there must be an error elsewhere 🙂

  22. One correction: an empty price doesn’t mean that the product is free. In WooCommerce, when a product doesn’t have a price (i.e. the price is an empty string), it’s not available for purchase.

    1. Thanks very much Diego, much appreciated – you’re right 🙂

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

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.