Created
March 27, 2017 18:00
-
-
Save rintoug/684fc9730ffc2ba6f1cadb3c00f212c7 to your computer and use it in GitHub Desktop.
Magento: Convert Price from Current Currency to Base Currency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
which is the filename and position to put this code to convert the currency kindly help me