3

I need to display two currencies simultaneously, but only for appearance, not function.

It should look like this 100euro/80USD or similar. I would like them to show side by side.

3 Answers 3

2

The simplest way (although not necessarily the best), would be to iterate over the currencies you've chosen to enable on your store in price.phtml.

At the top of price.phtml, just before the HTML, add

$store = Mage::app()->getStore();
$currentCurrency = $store->getCurrentCurrencyCode();
$currencies = array();

$codes = Mage::app()->getStore()->getAvailableCurrencyCodes(true);
if (is_array($codes) && count($codes) > 1) {
    $rates = Mage::getModel('directory/currency')->getCurrencyRates(
        Mage::app()->getStore()->getBaseCurrency(),
        $codes
    );

    foreach ($codes as $code) {
        if (isset($rates[$code])) {
            $currencies[$code] = Mage::app()->getLocale()
                ->getTranslation($code, 'nametocurrency');
        }
    }
}

foreach($currencies as $code => $value): 

?>

    <?php $store->setCurrentCurrency(null)->setCurrentCurrencyCode(strtoupper($code), false); ?>
    <?php if(strtoupper($code) != strtoupper($currentCurrency)) $this->setIdSuffix($this->getIdSuffix().'-'.strtolower($code)); ?>

Then at the very end of the HTML, close the loop and reset the currency,

<?php endforeach; ?>

<?php $store->setCurrentCurrency(null)->setCurrentCurrencyCode($currentCurrency); ?>
3
  • Fatal error: Call to a member function getCurrentCurrencyCode() on a non-object in C:\xampp\htdocs\app\design\frontend\base\default\template\catalog\product\price.phtml on line 2 Commented Dec 1, 2014 at 11:58
  • Did you forget $store = Mage::app()->getStore();? Commented Dec 1, 2014 at 14:18
  • I did sorry :D ITS WORKS !!! :) Do you have any idea how do the same to all prices ? i mean at shopping car...subtotal and staff like that. Btw big thanks from me for this :) Commented Dec 1, 2014 at 18:51
0

The only solution i know is to add them with javascript.

Maybe it is also possible to change the price.phtml and show two prices of different store views.

0

the first thing you need is the currency rates. magento has support for that, but the default service doesn't seem to be working anymore. i've written an extension that uses OpenExchangeRates.org - https://github.com/firewizard/Mandagreen_CurrencyRates

once you have these, you need to use a helper method everywhere the price is displayed - price.html or direct getPrice() calls.

the quickest solution is to use javascript, like Reinsch pointed out. you could pass the currency rate at the top of the page, then once the dom is ready replace all .price references with both prices.

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.