22

I can get the currency code from the order object. How can I derive currency symbol by using it? Any suggestions will be appreciated.

Sukeshini
  • 9,945
  • 18
  • 71
  • 126

6 Answers6

65

Try this one:

Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
Fabian Blechschmidt
  • 35,388
  • 8
  • 75
  • 182
kapil Zaru
  • 856
  • 6
  • 5
29

Store currency code eg. USD

$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();

store currency symbol eg. $

$currency_symbol = Mage::app()->getLocale()->currency( $currency_code )->getSymbol();

store currency name eg. US Dollar

$currency_name = Mage::app()->getLocale()->currency( $currency_code)->getName();
Suman K.C
  • 1,159
  • 14
  • 31
6

The following worked.

// store currency symbol eg. $ 
$currency_symbol = Mage::app()->getLocale()->currency( $currency_code )->getSymbol();
Sukeshini
  • 9,945
  • 18
  • 71
  • 126
3

Try:

$currencyCode   = '';
$currency       = $order->getOrderCurrency(); //$order object
if (is_object($currency)) {
    $currencyCode = $currency->getCurrencyCode();
}
$currencySymbol = Mage::app()->getLocale()->currency($currencyCode)->getSymbol();
var_dump($currencySymbol);
MagePsycho
  • 4,742
  • 4
  • 34
  • 64
2

Just pass the value in variable .. will return current currency format price

$Formatted_Price = Converted Price with Currency 
$Variable_Price  = Your Variable value
$Formatted_Price= Mage::helper('core')->currency($Variable_Price, true, false);
Ashvini K
  • 195
  • 1
  • 19
2

Using any given currency code you can derive the symbol using Zend_Locale:

$curr = new Zend_Currency('en_US');
echo $curr->getSymbol();
philwinkle
  • 35,751
  • 5
  • 91
  • 145
  • According to your solution we have to pass the locale to create Zend_Currency object right? What I expected was is there a way to get currency symbol regardless of locale? I mean by just passing the currency code can we get currency symbol in magento CE 1.7? – Sukeshini Sep 26 '13 at 16:00
  • You can pass any locale to zend currency – philwinkle Sep 26 '13 at 16:06
  • Yes. See the docs http://framework.zend.com/manual/1.12/en/zend.currency.html – philwinkle Sep 26 '13 at 16:06
  • My problem background is like this. I have several stores with several websites. I'm creating a php file which runs outside of the project and get all the order collection regardless of the store or any other factor. In that case if I get all details of an order I can get order total amount and currency code as separate values. I want to get the currency symbol and show the order total as a complete amount in my php file. So I cannot put whatever the locale I want. Thanks in advance. – Sukeshini Sep 26 '13 at 16:14