Magento: Convert Price from Current Currency to Base Currency and vice-versa

Here is a quick code to convert price amount from current currency of the shop to base currency. This is applicable when you have a multiple currency shop.

From the code below, you can convert any currency you desire. You just need the ‘From Currency Code’ and ‘To Currency Code’. In the example below, I will be converting the current currency price to base currency price. You can do the vice-versa as well.

The currency convert function has the following parameters:-
currencyConvert($amount, $from, $to=null)


$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); 
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
$price = 100;

// convert price from current currency to base currency
$priceOne = Mage::helper('directory')->currencyConvert($price, $currentCurrencyCode, $baseCurrencyCode); 

// convert price from base currency to current currency
$priceTwo = Mage::helper('directory')->currencyConvert($price, $baseCurrencyCode, $currentCurrencyCode); 

Changing price from any one currency to another

You can manually change any one currency price to another. Suppose, I have a price in USD and I want to change it to NPR. Then, I will write the following code:-


$from = 'USD';
$to = 'NPR';
$price = 10;

$newPrice = Mage::helper('directory')->currencyConvert($price, $from, $to); 

Hope this helps. Thanks.