How To Change the Price Of $0 Items To ‘FREE’ In WooCommerce

WooCommerceIf you are using WooCommerce (which has fast become my E-Commerce plugin of choice for WordPress), then sometimes you’ll run into the issue where you want to use the word “FREE” as the price when a product is $0.

I ran into this issue recently because I’ll probably be looking at including some free add-ons to ThirstyAffiliates eventually and wanted to make sure the templates would look proper when the price was set to 0.

I came up with this little snippet of code that you can just drop into your functions.php file in your theme. You’ll need WooCommerce installed as well, of course.

add_filter('woocommerce_get_price_html', 'changeFreePriceNotice', 10, 2);
function changeFreePriceNotice($price, $product) {
	if ( $price == wc_price( 0.00 ) )
		return 'FREE';
		return $price;

(adjust and tested for WooCommerce 3.0+)

Hope this helps if you’re looking to do the same and have your prices show as “FREE” instead of an ugly $0.

Josh Kohlbach

Josh is a software entrepreneur from Brisbane, Australia. He spends most of his time helping e-commerce store owners. This is his personal blog where he shares his thoughts and other tidbits on online business and life in general.

This Post Has 27 Comments

  1. Smittyhead

    This is almost everything that I have been trying to find out how to do. The only thing else is that I need it to show up in all thumbnail views like the “related products” and “latest products” views.

    If you can help me with that, you will be my hero.

  2. Carsten

    Hello Josh,
    I have the following problem. I run a shop under WordPress with WooCommerce 2.0.13.
    I do not want the prices to be displayed from the start. If the “price” is not filled in by me, I get the message “FREE”. I want to avoid this message. I want that the field remains “empty” not even zero, nothing.. only empty. How do I do that?
    I use an additional plugin that allows the customer to enter his own price.
    i will be happy if you can help me

    1. Josh Kohlbach

      Hey Carsten,

      Have you tried implementing the above code and just returning an empty string instead of the word FREE? It probably wouldn’t get rid of the element itself though so it depends on how you have styled the price with CSS as to if this is a workable solution for you.

  3. Nic

    Thanks so much for this code. It worked brilliantly! So glad to have people like you around when I type my questions into Google 🙂

  4. Jimmy

    Sweet! This works awesome. What if I wanted to display different “free” messages for different items? Say I wanted products a, b, and c to show “free” but products x, y, and z to show “no cost to you?”

    1. Josh Kohlbach

      You’d have to do it either by inspecting the product itself and checking it’s title/slug or, what I’d rather personally would be to use the product category which means you can assign a different free text to any category you like.

      This is completely untested but you could probably do something like:

      add_filter('woocommerce_free_price_html', 'changeFreePriceNotice', 10, 2);
      function changeFreePriceNotice($price, $product) {
      	$terms = get_the_terms( $product->ID, 'product_cat' );
      	$freetext = 'FREE';
      	// Check if appropriate product category
      	foreach ($terms as $term) {
      		if ((strcasecmp($term->slug,'my-cat-slug') == 0) {
      			$freetext = 'No cost to you!'
      	return $freetext;
  5. Tori Tran

    tks, it work.

  6. Mads

    Hi Josh

    I’ve searched all over the web and I’m using the plugin product add-on more as a variable, because I like the checkboxes better. I’ve set the regular price to 0 and added filter in functions.php to remove the “Free” price tag everywhere.

    Now my question is, if it is possible to show the first add-on’s price in the box on the category-page?

    I’m new into WP and codes, so I don’t now where to look up the right filter.

    Looking forward to your help. Best regards, Mads

    1. Mads

      Hi Josh,

      Thanks I’ll look into that. Then I have to find the right filter for the product add-on Price 🙂

  7. Tim


    Thank you so much for this code. This is great. I actually used it to mark original works as SOLD just by changing the wording. That way, if a painting sells, I can just change the price to Zero and it gets marked as sold. (I also update it as out of stock, so no one will try to buy it – but I didn’t think this was clear enough on the front page)

    Thanks again, I really appreciate it!

  8. Peter

    Worked great for me, using child theme functions.php. Thanks!

  9. TB

    This doesnt seem to work for variable products, only simple products. Do you know how to make it work for both? I am changing the “FREE” to something else but many of my products have multiple variations.

  10. Jenna

    How can I do something similar for wothemes booking extension?
    I would like to change the price that pops up under the calendar when you select your date and time to something like “We will call you to confirm” Your code didn’t seam to work for this.

    I would also like to change it on the cart page to the same.

    1. Josh Kohlbach

      Hi Jenna, you might have to reach out to the Bookings extension people for that one, sorry!

  11. Kimberly

    Thank you!!! Works perfectly!!

  12. Alix

    Hi team, wondering if anyone knows an update on this for the newest Woocommerce 3.0? It doesn’t look like ‘woocommerce_free_price_html’ exists anymore?

    Anyone have this working for Woocommerce 3? Cheers!

  13. Bashia BMG

    Works perfectly. Thank you for sharing the snippet.

  14. Jacqui

    Why are you printing out to the error log in your snippet?

    1. Josh Kohlbach

      Good spot Jacqui, you can drop that line. I’ll edit the code snippet.

  15. Jess

    Works like a charm. Thanks! 🙂

  16. Anita

    I do not use woocommerce in my gevity forms form.
    Only the normal product fields. I would need the same function for it.
    The word free should also appear in the notifications.
    So exchange all 0,00 to Free.
    Maybe someone knows a solution to my problem.
    (Excuse my english)
    Thank you!!!

  17. Maurice


    Im looking for a plugin or option to could replace the value in the price field with a custom text in woocommerce single product.
    So currently in woocommerce each product has a numeric value/price for example Product 1: $12.00 Product 2: $18,00
    Is there an option to replace this value for each single product with custom text for example Product 1 wil have value: Amber, product 2 will have value: Ginger and so on.


  18. Filip

    You my friend are a legend…..Hope someone is paying you big money for your skillz

  19. saeed

    thank you veeeeeeeeeeeery much

Leave a Reply