NB: Make sure you do a back up of your theme, files and database before attempting the tutorials


---- Last modified : Sep 01 2022

Estimated reading time : 0 minutes, 47 seconds - 76 words

Woocommerce Price: Here’s a short tutorial on how to display free as a price once an item’s price is set at 0$.

We will use the woocommerce_get_price_html filter which will verify if an item’s price is 0$ or empty and then return the text with the $price variable.

Add this filter in your functions.php file.

// Get Free if the price Woocommerce = 0

add_filter( 'woocommerce_get_price_html', 'themepress_price_html', 10, 2 );
function themepress_price_html( $price, $product ) {
  if( $product->get_price() == 0 ||  $product->get_price() == '') {
  $price = '<span class="woocommerce-Price-amount amount">Gratuit</span>';
return $price;

Once the condition is configured, you can display the text you want insde the woocommerce-Price-amount span tag.

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>