A simple, powerful and independent e-commerce platform.
Sell anything with ease.

Display FREE if price zero or empty

If a product has no price or a price set to zero it shows as price 0.00. It can look much nicer to have it shown as FREE.

/**
* Display FREE if price zero or empty
*/

add_filter('woocommerce_get_price_html', 'cc_price_free_zero_empty', 9999, 2);

function cc_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;

}
View Raw Code ID: 997