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?
Instead of showing the default WooCommerce pricing label of $0.00, you want to show custom text,like “FREE” or “Download Now”.
In WooCommerce when product price is zero or empty then on cart page or checkout page it will show zero price.

null

But I still believe “FREE” looks much better than “$0.00”. It’s much more enticing, isn’t it?

Example :


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

Enjoy

Leave a Comment

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

Scroll to Top