WooCommerce: Display “FREE” Instead of $0.00 Price

In older versions of WooCommerce free prices used to display as “FREE!” and products with empty prices were not publishable/purchasable. 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 WooCommerce 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

/**
* @snippet       Display FREE if Price Zero or Empty - WooCommerce Single Product
* @how-to        Get CustomizeWoo.com FREE
* @author        Rodolfo Melogli
* @testedwith    WooCommerce 5
* @donate $9     https://businessbloomer.com/bloomer-armada/
*/
 
add_filter( 'woocommerce_get_price_html', 'bbloomer_price_free_zero', 9999, 2 );
  
function bbloomer_price_free_zero( $price, $product ) {
    if ( $product->is_type( 'variable' ) ) {
        $prices = $product->get_variation_prices( true );
        $min_price = current( $prices['price'] );
        if ( 0 == $min_price ) {
            $max_price = end( $prices['price'] );
            $min_reg_price = current( $prices['regular_price'] );
            $max_reg_price = end( $prices['regular_price'] );
            if ( $min_price !== $max_price ) {
                $price = wc_format_price_range( 'FREE', $max_price );
                $price .= $product->get_price_suffix();
            } elseif ( $product->is_on_sale() && $min_reg_price === $max_reg_price ) {
                $price = wc_format_sale_price( wc_price( $max_reg_price ), 'FREE' );
                $price .= $product->get_price_suffix();
            } else {
                $price = 'FREE';
            }
        }
    } elseif ( 0 == $product->get_price() ) {
        $price = '<span class="woocommerce-Price-amount amount">FREE</span>';
    }  
    return $price;
}

Where to add this snippet?

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

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

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent 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.

87 thoughts on “WooCommerce: Display “FREE” Instead of $0.00 Price

  1. Still works! Great! Thanks for free solution

  2. This works great! However, it does not work for Variable Products. Example: if Variation 1 costs $0 and Variation 2 costs $10 the front-end simply says “FREE” and doesn’t display the price range. Is there a way to show the price range if the product type is set to Variable Product?

    Thanks again for the awesome code!

    1. Just released a new version, please test!

  3. Hi there, fantastic resources on this site, thank you!

    I’m wondering if you’d know how I could get this to working with WooCommerce Bookings / bookable product types?

    Would appreciate your thoughts, cheers!

    1. Hi there, 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. Can this be done also for fees?

    1. Of course!

  5. It says “free” on a product page, but cart and checkout page still display the amount. Which I want.

    1. Hi Nate, 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!

  6. Thanks man , its working well on 5.4.2
    I also made a little changes for products that Shop Owner wants to add “Contact for Price” instead of price .
    For some purposes i want to display a “Contact for Price” link instead of price .
    So this snippet creates a “Contact for Price” link for all Products with specific price .
    You can put your WhatsApp link for example instead of price
    In this example , “Contact for Price” link will displayed for products with price “1” :
    It mean you must put number “1” for product to display this link.

    /** Snippet Start
    * @snippet       Display FREE if Price Zero or Empty - WooCommerce Single Product
    * @how-to        Get CustomizeWoo.com FREE
    * @author        Rodolfo Melogli
    * @testedwith    WooCommerce 3.8
    * @donate $9     https://businessbloomer.com/bloomer-armada/
    */
      
    add_filter( 'woocommerce_get_price_html', 'bbloomer_price_contact_instead_1_empty', 9999, 2 );
       
    function bbloomer_price_contact_instead_1_empty( $price, $product ){
        if ( '' === $product-&gt;get_price() || 1 == $product-&gt;get_price() ) {
            $price = '
    			<a href="#" rel="nofollow ugc"> Contact for Price </a>
    		';
        }  
        return $price;
    }
    /** Snippet Ends
    
    1. Nice!

  7. I used your code, it works fine,
    so I want to appear specifically for the sale price while the regular price is still visible, can you help me
    as an example
    Default: price> $ 30.00 – $ 0.00
    Your code: price> FREE
    My goal: price> $ 30.00 – FREE

    Thank you very much

    1. Ady, 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!

  8. How to you change the $0.00 to “free” on the my-account page for the orders column? It still shows “$0.00 for 2 items” after the order is placed.

    1. Hi Matt, 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!

  9. Still works! Thank you! Exactly what I needed.

    1. Genial!

  10. Works for me good – june 2020

    Added to functions.php of child theme.

    WordPress: 5.4.1
    WooCommerce: 4.2.0
    PHP: 7.4
    Theme: Citadela 1.4.3

    1. Thank you!

  11. Hi, which part of the code do I have to modify for sale price 0 to Free?

    1. Hi KJ, 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!

  12. I just wanna display in Woocommerce Category, or product loop, please !

    1. Hello, 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!

  13. Hello, thanks for the code, but I want to hide it totally without showing free.. I mean when price is Zero I don’t want to show anything not even free.

    Is it possible?

    1. Sure, instead of “FREE” use “”

  14. Not work for me 🙁

    1. Hi Erza, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?

      To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!

      R

  15. Still working in March 2020, thanks again Rodolpho !

    1. Great!

  16. Thank you. Still working like a charm in January, 2020.

    1. Fantastic!

  17. Awesomeness! Thank you for this. Works perfectly with WooCommerce 3.8.1

    1. Great!

  18. Hello, snippet works amazing! Thanks… But it only displays on product page, on cart, checkout and send emails it still displays 0… Is there a way to change the price sitewide? Thanks a lot.

    1. Hi there, 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!

  19. Works perfectly Many thanks!

    1. Thank you!

  20. The code worked perfectly, but it still shows me the Buy Button. I would like to know if you can provide an add-on to the code that can hide the Buy button when you enter Price value 0

    1. Hi Henrique, 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!

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

    -Dwindi, Indonesia

    1. Great!

  22. 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!

  23. 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!

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

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

  26. Still works in March 2019

    1. Awesome!

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

    1. Cool!

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

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

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

  31. 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 🙂

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

    1. Great 🙂

  33. This still works well. Thanks!!!

    1. Awesome!

  34. 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?

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

    1. Excellent 🙂

  36. 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>';
      1. Ah, excellent, thank you Jack!

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

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

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

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

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

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

  42. 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 shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published.