1. WordPress
  2. WooCommerce
  3. How to Show Free instead of 0 dollars in WooCommerce

How to Show Free instead of 0 dollars in WooCommerce

It is possible to show the word “FREE” as the price instead of $0.00 in WooCommerce when the product is actually free.

Showing the word Free instead of $0.00 is more noticeable to users and less confusing especially when just want to add some free products or gifts for your customers to choose from.

All you need to do is add the following code snippet to your theme’s function.php file:

/**
* @snippet       Display FREE if Price Zero or Empty - WooCommerce Single Product
* @author        Vigilante Marketing
* @testedwith    WooCommerce 3.8
*/
  
add_filter( 'woocommerce_get_price_html', 'vm_price_free_zero_empty', 9999, 2 );
   
function vm_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;
}
Search
Generic filters
Share Article

Related Articles

Tools + Resources

Freelance Hourly Rate Calculator

Social Media Image Sizes

Need Support?

Website Maintenance and Support

Your website security is important to us! We run frequent security checks and regularly update software to guarantee the integrity of your site continues to stay reliable and intact.

Support You Can Count On

Menu