Change Zero Price to Free Label
Replaces the WooCommerce '$0.00' price display with the word 'Free' for products that have a zero price, giving a more customer-friendly presentation.
PHPby SnipCraft
php
<?php
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
add_filter( 'woocommerce_get_price_html', 'scseed_free_price_label', 10, 2 );
function scseed_free_price_label( $price, $product ) {
// Only override simple, non-empty zero prices.
if ( '' !== $product->get_price() && 0.00 === (float) $product->get_price() ) {
return '<span class="woocommerce-Price-amount amount">' . esc_html__( 'Free', 'woocommerce' ) . '</span>';
}
return $price;
}#display#free-products#pricing#ux#woocommerce