How to hide zero price and show “Free” text @ WordPress Help

How to hide zero price and show “Free” text @ WordPress Help


When you offer in your online store built with WooCommerce free products Sometimes It’s confusing to show €0.00 as the priceand it would be better to show some text making it clear that the product is free, don’t you think?

woocommerce product zero price

To achieve this, you just need to add a few lines of code to your functions.php file or whatever method you prefer for this type of customization, like this:

/* Mostrar texto GRATIS en vez de precio cero */
add_filter( 'woocommerce_get_price_html', 'ayudawp_precio_cero_gratis', 9999, 2 );
function ayudawp_precio_cero_gratis( $price, $product ){
if ( '' === $product->get_price() || 0 == $product->get_price() ) {
$price="<span class="woocommerce-Price-amount amount">GRATIS</span>";
}
return $price;
}

In this code If a product’s price is null on the individual product page, we replace it with the text “FREE”, which you can change to whatever you likemaking the product clearer for free.

woocommerce product zero price free

It’s that easy and quick.

Did you like this article? You have no idea what’s wrong with you a YouTube!



Source link

Related Posts

Leave a Reply

Open chat
Scan the code
Hello 👋
Can we help you?