Display the word "Free" for products priced at zero instead of showing $0.00.
add_filter( 'woocommerce_get_price_html', function ( string $price, WC_Product $product ): string {
if ( '' !== $product->get_price() && 0.0 === (float) $product->get_price() ) {
return '<span class="amount">Free</span>';
}
return $price;
}, 10, 2 );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
Free downloads, samples and lead magnets look odd with “$0.00” next to them. “Free” is clearer and more inviting.
The woocommerce_get_price_html filter returns the price HTML shown everywhere a product’s price appears. If the price is set and equals zero, the snippet replaces it with “Free”.
Products with no price at all keep WooCommerce’s behaviour, which hides the price and the Add to cart button.
Set a product’s price to 0 and view it on the shop page. It should say “Free”.