3
votes

I'm trying to do something fairly simple, but it's proving quite tricky.

I want my product page to display the price in GBP and EUR (however they can only buy using whichever currency is currently set on the store view).

If I could find out how to get the currency rate, I could make the calcualtions myself to display the correct price, but I've had no luck so far. This is what I've tried:

$allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
$euro = Mage::getModel('directory/currency')->getCurrencyRates('EUR', array_values($allowedCurrencies));

Displays '1.00000' which isn't the rate (should be 1.1948)

I have done all the configuration required and have imported the rates with WebserviceX.

Any help would be much appreciated.

1

1 Answers

6
votes

I managed to get the currency rates, my code was almost correct:

$baseCode = Mage::app()->getBaseCurrencyCode();      

$allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies(); 
$rates = Mage::getModel('directory/currency')->getCurrencyRates($baseCode, array_values($allowedCurrencies));

var_dump($rates);