Get currency rates

Tweet, share & co

tweet fb share g+ share

Tags


Description

Get currency rates

Code

    /**
     * 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));

    $allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();

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