3

I am using Magento v1.9.1.0. and I have a problem with currency symbol position when having locale set to English and currency to Euro. It displays:

€24.10

I would like to show it like where locale is set to Slovenian and currency to Euro:

24.10 €

If I change 'lib/Zend/Locale/Data/en.xml' currency format, then it won't display like it should for US dollars currency symbol($).

Does anyone know the solution for that kind of problem?

4 Answers 4

4

You can observe currency_display_options_forming event dispatched in Mage_Core_Model_Locale class

<currency_display_options_forming>
    <observers>
        <foo_bar>
            <class>foo_bar/observer</class>
            <method>currencyDisplayOptionsForming</method>
        </foo_bar>
    </observers>
</currency_display_options_forming>

Observer:

class Foo_Bar_Model_Observer
{
    public function currencyDisplayOptionsForming(Varien_Event_Observer $observer)
    {
        if (Mage::app()->getLocale()->getLocaleCode() == 'en_US' &&
            Mage::app()->getStore()->getCurrentCurrency()->getCode() == 'EUR'
        ) {
            $options = $observer->getEvent()->getCurrencyOptions();
            $options['position'] = Zend_Currency::RIGHT;
        }

        return $this;
    }
}

Look in Zend_Currency class for additional options.

1
  • that did positioned the curr on right side, but without padding, or space between number and sign! I feel that in that case best bet is fiddle with xml files in /lib/Zend/Locale/Data dir,, which is totaly putting it off :( Commented Dec 16, 2016 at 13:31
0

You can customize it at price.phtml .

$locale = Mage::app()->getLocale()->getLocaleCode();

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

 if($locale=='sl_SI') { 

echo $_price;echo $currencySymbol; 

} 
1
  • Sorry, but that is not what I want. I have $locale set to en_US and $currencySymbol with your code gives me $, but my currency set in admin is €. My question was if it is possible to have locale set to 'en_US' and currency to '€' so that it displays like that: 24.10€ and not €24.10. But thank you for your effort.
    – anitr
    Commented Jan 28, 2015 at 13:38
0

I found out that it is ok for store in English language to display currency symbol before value, because the position of currency symbol € is different in every country and it depends on grammar. So, €24.10 will be fine. Thank you anyway.

1
  • 1
    Congratulations! Please accept a correct answer anyway as you may not be the only person to ask this question in the History of the Internet. Commented Jan 28, 2015 at 14:56
0

go to ( lib/Zend/Currency.php ) move to line 196

if ($options['position'] !== self::STANDARD) {
    $value = str_replace('¤', '', $value);
    $space = '';
    if (iconv_strpos($value, ' ') !== false) {
        $value = str_replace(' ', '', $value);
        $space = ' ';
    }

    if ($options['position'] == self::LEFT) {
        $value = '¤' . $space . $value;//here the currency before the value (price)
    } else {
        $value = $value . $space . '¤';
    }
}

TO MAKE THE CURRENCY AFTER THE VALUE (PRICE) :

if ($options['position'] !== self::STANDARD) {
    $value = str_replace('¤', '', $value);
    $space = ' ';//make space between the value and the currency
    if (iconv_strpos($value, ' ') !== false) {
        $value = str_replace(' ', '', $value);
        $space = ' ';
    }

    if ($options['position'] == self::LEFT) {
        $value = $value . $space . '¤' ;//print the currency after the value
    } else {
        $value = $value . $space . '¤';
    }
}

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.