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 8
* @community     https://businessbloomer.com/club/
*/
 
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', 'woocommerce' ), $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', 'woocommerce' ) );
                $price .= $product->get_price_suffix();
            } else {
                $price = __( 'Free', 'woocommerce' );
            }
        }
    } elseif ( 0 == $product->get_price() ) {
        $price = '<span class="woocommerce-Price-amount amount">' . __( 'Free', 'woocommerce' ) . '</span>';
    }  
    return $price;
}

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

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. Follow @rmelogli

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

  1. Hey Rodolfo, love this code snippet, however, it seems to now be displaying “FREE” for products with an empty price field, whereas it used to work only on products with 0 in the price. Do you have a tweak for that please? Thanks!

    1. Hi Rae, just tested it and it only shows “Free” for price = 0. If price is empty it doesn’t show it, so it must be something else within your custom setup

  2. Hi,
    Thank you but is this code WPML friendly? Looks like not as text strings are not registred. Thank you

    1. Try with the new snippet version please, and let me know

  3. Confirming this still works like a charm. I am using WooCommerce v7.7.2 and this code works great! Thanks so much for providing this for free 🙂

  4. Hey,

    It is not working for me 🙁
    Does it matter if the price is in $s or £s?

    1. Hi Ali, thanks so much for your comment! I just retested this on the latest version of WooCommerce and it still works. Unfortunately this looks like custom troubleshooting work and I cannot help here via the blog comments.

  5. Still works! Great! Thanks for free solution

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

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

  8. Can this be done also for fees?

    1. Of course!

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

  10. 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
    * @community     https://businessbloomer.com/club/
    */
      
    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!

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

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

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

    1. Genial!

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

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

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

  17. 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 “”

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

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

    1. Great!

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

    1. Fantastic!

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

    1. Great!

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

  23. Works perfectly Many thanks!

    1. Thank you!

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

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

    -Dwindi, Indonesia

    1. Great!

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

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

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

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

  30. Still works in March 2019

    1. Awesome!

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

    1. Cool!

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

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

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

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

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

    1. Great 🙂

  37. This still works well. Thanks!!!

    1. Awesome!

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

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

    1. Excellent 🙂

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

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

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

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

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

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

  46. 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? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. 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 the Business Bloomer Club to get quick WooCommerce support. Thank you!

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