Añade un texto antes del precio en los productos de WooCommerce.
Para todos los productos:
add_filter('woocommerce_get_price_html', 'wc_price_prefix');
function wc_price_prefix($price) {
$text_to_add_before_price = 'Prefijo: ';
return $text_to_add_before_price.$price;
}
Para los productos en oferta:
add_filter('woocommerce_get_price_html', 'wc_price_prefix_discounts', 100, 2);
function wc_price_prefix_discounts($price, $product) {
if ($product->is_on_sale()) {
$text_to_add_before_price = str_replace('<ins>', '<ins><br>En oferta: ', $price);
return $text_to_add_before_price;
} else {
return $price;
}
}