How to format price in Magento?
Mohan Dave · · 2590 Views
There are a couple of methods to format price in Magento. The easiest and most used is:
Mage::helper("core")->currency($price, $format, $includeContainer)
For Example:
echo Mage::helper("core")->currency(115, true, false)
//if your currency is Euro then output will be: €115.00
Sometimes you don’t need currency symbols in your prices, then you will need something like:
Mage::getModel('directory/currency')->setData("currency_code", Mage::app()->getStore(null)->getCurrentCurrency()->getCode())->format(
$product->getFinalPrice(),
array('display' =>Zend_Currency::NO_SYMBOL), false);
The value for the display can be:
Zend_Currency::NO_SYMBOL
: It will remove the symbol and show only the price.Zend_Currency::USE_SYMBOL
: Shows the currency symbol before the price.Zend_Currency::USE_SHORTNAME
: Shows the abbreviation of the currency before the price.Zend_Currency::USE_NAME
: shows the full name of the currency before the price.
Example outputs:
Zend_Currency::NO_SYMBOL: 115.00
Zend_Currency::USE_SYMBOL: €115.00
Zend_Currency::USE_SHORTNAME: EUR115.00
Zend_Currency::USE_NAME: EURO115.00
0
Please login or create new account to add your comment.