To display price with currency symbol:
$finalPrice = 55;
Mage::helper('core')->currency($finalPrice, true, false);
// static mixed currency (float $value, [bool $format = true], [bool $includeContainer = true])
OR
$finalPrice = 55;
$formattedPrice = Mage::helper('core')->formatPrice($finalPrice, false);
To display price without currency symbol:
$finalPrice = 55;
Mage::helper('core')->currency($finalPrice, false, false);
OR
$finalPrice = 55;
Mage::getModel('directory/currency')->formatTxt($finalPrice, array('display' => Zend_Currency::NO_SYMBOL));
To get currency symbol and symbol name by currency code:
$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
$currency_symbol = Mage::app()->getLocale()->currency( $currency_code )->getSymbol();
$currency_name = Mage::app()->getLocale()->currency( $currency_code)->getName();
To convert Price from Current Currency to Base Currency and vice-versa:
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
$price = 100;
// convert price from current currency to base currency
$priceOne = Mage::helper('directory')->currencyConvert($price, $currentCurrencyCode, $baseCurrencyCode);
// convert price from base currency to current currency
$priceTwo = Mage::helper('directory')->currencyConvert($price, $baseCurrencyCode, $currentCurrencyCode);
To change price from any one currency to another:
$from = 'USD';
$to = 'NPR';
$price = 10;
$newPrice = Mage::helper('directory')->currencyConvert($price, $from, $to);
Reference:
http://blog.chapagain.com.np/magento-format-price/
http://magento.stackexchange.com/questions/8450/how-to-get-currency-symbol-by-currency-code
http://blog.chapagain.com.np/magento-convert-price-from-current-currency-to-base-currency-and-vice-versa/
No comments:
Post a Comment