`
kirenenko04
  • 浏览: 152335 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

How to get Currency Rates?

 
阅读更多

You can keep any currency code instead of basecurrency.

/**
 * Get the base currency
 */
$baseCurrencyCode = Mage::app()->getBaseCurrencyCode();     
 
/**
 * Get all allowed currencies
 * returns array of allowed currency codes
 */
$allowedCurrencies = Mage::getModel('directory/currency')
                            ->getConfigAllowCurrencies();   
 
/**
 * Get the currency rates
 * returns array with key as currency code and value as currency rate
 */
$currencyRates = Mage::getModel('directory/currency')
                        ->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));

 Similarly, you can get currency rates for any currency code. But remember that the currency should be set as allowed currency in
System -> Configuration -> GENERAL -> Currency Setup -> Currency Options -> Allowed Currencies

$allowedCurrencies = Mage::getModel('directory/currency')
                            ->getConfigAllowCurrencies();   
 
/**
 * Get currency rates for Nepalese Currency
 */
$currencyRates = Mage::getModel('directory/currency')
                        ->getCurrencyRates('NPR', array_values($allowedCurrencies));

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics