WooCommerce : Display “FREE” if Product Price is 0 or Empty On WooCommerce Cart Page Or Checkout Page.

Code

WooCommerce : Display “FREE” if Product Price is 0 or Empty On WooCommerce Cart Page Or Checkout Page.

Do you ever need to replace the default WooCommerce pricing label for a free product?

If we ask any user what will he/she like the text “FREE” or a price tag of “0.00”. Majority will say “Free” Attracts More.

Now Let’s talk about WooCommerce ,In WooCommerce when product price is zero or empty then on cart page or checkout page and product page will show zero price ($0.00).

Instead of showing the default WooCommerce pricing label of $0.00, you want to show custom text,like “FREE” or “Download Now”.

null

In Previous Image we so price tag , But I still believe “FREE” looks much better than “$0.00”. It’s much more enticing, isn’t it?

For Cart and Checkout Page:

function FreeCartItemPriceCustomLabel( $price, $cart_item, $cart_item_key ) {
 $FreeLabel = '<span class="amount" style=" color: #f7ad06 !important; ">' . __('Free') . '</span>';
 if( $cart_item['data']->get_price() > 0 ){
  return $price;
 }else{
  return $FreeLabel;
 }
}
add_filter('woocommerce_cart_item_subtotal','FreeCartItemPriceCustomLabel', 21, 3);
add_filter('woocommerce_cart_item_price','FreeCartItemPriceCustomLabel', 21, 3);
null

null

For Single Product Page:

Display “FREE” if WooCommerce Product Price is 0 or Empty on Single Product Page

function FreeCartItemPriceCustomHtml( $price, $product ) {
 if ( '' === $product->get_price() || 0 == $product->get_price() ) {
  $price = 'FREE';
 }  
}
add_filter('woocommerce_get_price_html','FreeCartItemPriceCustomHtml', 21, 2);

Or

function FreeCartItemPriceCustomHtml( $price, $product ) {
 if ( empty( $product->get_price() ) ) {
  $price = 'FREE';
 }  
}
add_filter('woocommerce_get_price_html','FreeCartItemPriceCustomHtml', 21, 2);

Using “if” conditional statement we are just checking the price to make sure that it is “empty” i.e. free or price zero, and then if it is, returning different label text which in the case above is the word “FREE”.

If the product is not free, then we don’t change anything and return the original price.

Shiv kumawat

Executive Director & CEO

"Shiv kumawat is the Executive Director and CEO of Eoxys It Solution LLP and the strategic mind behind the company"s growth. His expertise in operational efficiency and team leadership empowers his colleagues to excel and innovate.”

Latest Posts

Factories of the Future: How AI is Powering a Manufacturing Revolution in the USA

  Factories of the Future: How AI is Powering a Manufacturing Revolution in the USA A New Era for American…

Shafeeq Khan
August 28, 2025

Reinventing Everyday Life: The Rise of Artificial Intelligence in Finance for 2025

  Reinventing Everyday Life: The Rise of Artificial Intelligence in Finance for 2025 A New Financial Landscape Artificial intelligence isnʼt…

Shafeeq Khan
August 14, 2025

AI in Retail USA Redefining Shopping, Operations, and Experiences in 2025

  AI in Retail USA: Redefining Shopping, Operations, and Experiences in 2025 How Artificial Intelligence Is Changing Retail in the…

Shafeeq Khan
August 11, 2025
, ,

Leave a Reply

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