Skip to content

Instantly share code, notes, and snippets.

@rintoug
Created March 27, 2017 18:00
Show Gist options
  • Save rintoug/684fc9730ffc2ba6f1cadb3c00f212c7 to your computer and use it in GitHub Desktop.
Save rintoug/684fc9730ffc2ba6f1cadb3c00f212c7 to your computer and use it in GitHub Desktop.
Magento: Convert Price from Current Currency to Base Currency
<?php
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
$price = 200;
// convert price from base currency to current currency
$priceTwo = Mage::helper('directory')->currencyConvert($price, $baseCurrencyCode, $currentCurrencyCode);
//convert price from current currency to base currency
$allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
$rates = Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
// the price converted
$price=$price/$rates[$currentCurrencyCode];
print $price;
@gnkafridi
Copy link

which is the filename and position to put this code to convert the currency kindly help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment