WooCommerce Change “$0.00” to “Free”

WooCommerce product showing custom text "free" instead of 0

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

If you have products which are free, the single product template and archive loop item will display the price as “$0.00” by default. This default display could confuse users. A better options would be to display text like “Free” or “Price on application”. This snippet looks at whether a product has a price or if it is set to 0 and if true, will display custom text.

				
					/**
 * Snippet Name:	WooCommerce Change "$0.00" to "Free"
 * Snippet Author:	ecommercehints.com
 */

add_filter( 'woocommerce_get_price_html', 'ecommercehints_change_zero_price_display', 10, 2 );
function ecommercehints_change_zero_price_display( $price, $product ) {
if (empty($product->get_price()) || $product->get_price() == 0) { // If price is not entered or set to 0
$price = __( 'Free', 'woocommerce' );
}
return $price;
}
				
			

Snippet Benefits

  • Override the display for the $0.00 price when a product does not have a price or if it is set to 0 (free).
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

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

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers