Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decimal Separator in price woocommerce

Hi everyone I have this configuration in my woocommerce enter image description here

And in my product I have this enter image description here

but when I show the price it return me "4.95" instead of "4,95"

I use this to get the price

$price = get_post_meta( get_the_ID(), '_regular_price', true);

Any idea!

like image 503
Stone Avatar asked Feb 07 '23 19:02

Stone


1 Answers

Use the wc_price function to format the number.

$price = get_post_meta( get_the_ID(), '_regular_price', true);
$formatted_price = wc_price( $price );

Note: For versions < 2.1.0, use woocommerce_price.

like image 121
Derek Avatar answered Feb 09 '23 09:02

Derek