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.

1
  • 1
    If you found one of this answers useful, please flag them as correct answer. Dec 21, 2013 at 18:27

6 Answers 6

65

Try this one:

Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
1
  • Please mark this answer as correct. Nov 23, 2015 at 10:29
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();
1
  • This does not work in 1.7 Nov 23, 2015 at 10:24
6

The following worked.

// store currency symbol eg. $ 
$currency_symbol = Mage::app()->getLocale()->currency( $currency_code )->getSymbol();
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);
5
  • Mage::app()->getLocale() will return the current locale object isn't it? What I want is get the currency symbol of the given currency code regardless of locale.
    – Sukeshini
    Sep 25, 2013 at 6:28
  • Please check once the code. It should work.
    – MagePsycho
    Sep 25, 2013 at 6:34
  • It won't work if you've set a different symbol in your locale. It would still return your default currency symbol.
    – Shathish
    Sep 25, 2013 at 6:56
  • @MagePsycho: Checked. It is not working.
    – Sukeshini
    Sep 25, 2013 at 8:26
  • Can you paste your code? I just tested and it was working fine for me.
    – MagePsycho
    Sep 25, 2013 at 8:30
2

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

$curr = new Zend_Currency('en_US');
echo $curr->getSymbol();
4
  • 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, 2013 at 16:00
  • You can pass any locale to zend currency
    – philwinkle
    Sep 26, 2013 at 16:06
  • Yes. See the docs framework.zend.com/manual/1.12/en/zend.currency.html
    – philwinkle
    Sep 26, 2013 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, 2013 at 16:14
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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.