Answer the question
In order to leave comments, you need to log in
How to display label if price is 0 Woocommerce?
Hi all. There is such a need in the Woocommerce store, when the price is zero, that is, a free product, then display your inscription. I do this action
function filter_woocommerce_empty_price_html($price, $_product) {
if ($_product->get_price() == 0) return __('<span class="woocommerce-Price-amount amount">Цену уточняйте</span>');
return $price;
}
add_filter( 'woocommerce_empty_price_html', 'filter_woocommerce_empty_price_html', 10, 2 );
Answer the question
In order to leave comments, you need to log in
Helped to decide
add_filter( 'woocommerce_get_price_html', 'product_price_free_zero_empty', 100, 2 );
function product_price_free_zero_empty( $price, $product ){
if ( '' === $product->get_price() || 0 == $product->get_price() ) {
$price = '<span class="woocommerce-Price-amount amount">Цену уточняйте</span>';
}
return $price;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question