Add a custom text before the price display in WooCommerce
10,011
You have just to inverted the price and the text:
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
function cw_change_product_price_display( $price ) {
// Your additional text in a translatable string
$text = __('TEXT');
// returning the text before the price
return $text . ' ' . $price;
}
This should work as you expect…
Related videos on Youtube
Author by
Emanuell Vieira
Updated on June 04, 2022Comments
-
Emanuell Vieira almost 2 years
In WooCommerce, I'm using this code to put a text in the price display:
function cw_change_product_price_display( $price ) { $price .= ' TEXT'; return $price; } add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' ); add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
The page displays like
"$99,99 TEXT"
I want to make it displays like this:
"TEXT $99,99"
Thank you for the help.
-
Dimitris Filippou over 6 years
$price = 'TEXT '.$price;
-
Emanuell Vieira over 6 yearsWorked just fine! Thank you for the fast anwser!
-