Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format price in the current locale and currency

Tags:

php

magento

I use :

$product->getPrice(); 

to get the unformatted price that I can calculate "quantity X price" with ajax.

I want to reformat the total in the current locale and currency. How can I do that?

like image 978
Ahmed Ala Dali Avatar asked Jul 18 '11 08:07

Ahmed Ala Dali


People also ask

What is the format for currency?

United States (U.S.) currency is formatted with a decimal point (.) as a separator between the dollars and cents. Some countries use a comma (,) instead of a decimal to indicate that separation.

How do I format USD?

USD is the international currency code established by the ISO to represent the American dollar. It is composed of the country code ( US ), followed by the letter "D" for "dollar." Write the dollar figure first, followed by a non-breaking space and the code: 350 000 USD.

How would you display currency and currency symbol of a country?

Display Currency symbol to the right using Angular Currency Pipe. A lot of european countries use the currency symbol at the right side of currency value (France, Germany, Spain, Italy countries).


2 Answers

I think Google could have answered your question ;-) See http://blog.chapagain.com.np/magento-format-price/.

You can do it with

$formattedPrice = Mage::helper('core')->currency($finalPrice, true, false); 
like image 100
Simon Avatar answered Oct 09 '22 13:10

Simon


$formattedPrice = Mage::helper('core')->currency($_finalPrice,true,false); 
like image 40
Silas Palmer Avatar answered Oct 09 '22 14:10

Silas Palmer