Jump to content

Price format in 1.7.6


Recommended Posts

$iso_code = Context::getContext()->currency->iso_code;

$product = new Product ((int)Tools::getValue ('id_product'));

$price = $product->price;

$formated_price = Context::getContext()->currentLocale->formatPrice($price, $iso_code);

Link to comment
Share on other sites

Thanks knacky, your code is almost what I need, but instead of $product->price (which in my case displays 0.000) should be $product->getPrice(). But with the main issue you helped me, which was the Locale:

This was how I was trying to use it, and it will not work: Locale::formatPrice($price, $iso_code), it has to be done as you wrote:
 

Context::getContext()->currentLocale->formatPrice($price, $iso_code);

or in the module:

$this->context->currentLocale->formatPrice($price, $iso_code);

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...