Home » Magento

Magento: How to get Currency Rates?

16 July 2010 2,093 views Popularity: 5% Share/Bookmark

email

You can see the currency Rates from Magento Admin
System -> Manage Currency Rates

You can change base currency and allowed currencies from
System -> Configuration -> GENERAL -> Currency Setup -> Currency Options

Now, here I will show you how you can get currency rates values for any given currency code.

Here, I will be fetching currency rates for base currency. 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));

Hope this helps.

Related posts:

  1. Magento: Convert Price from Current Currency to Base Currency and vice-versa
  2. Magento: Setup multiple currency shop
  3. Magento: Show Currency Selector in right sidebar
  4. Magento: Show Currency Selector in header
  5. Magento: How to change Currency symbol by Model Override ?
  6. Magento: How to change Currency symbol ?
  7. Magento: Get order option of configurable and bundle product in cart
  8. Magento: How to upload file?
  9. jQuery: Grey out background and preview image as popup
  10. Magento: Get country and region collection
  • http://topsy.com/blog.chapagain.com.np/magento-how-to-get-currency-rates/?utm_source=pingback&utm_campaign=L2 Tweets that mention Magento: How to get Currency Rates? | Mukesh Chapagain’s Blog — Topsy.com

    [...] This post was mentioned on Twitter by Joonkiri J, Tech Blog. Tech Blog said: Magento: How to get Currency Rates? (http://bit.ly/dpuy4a) #currency_rates #Magento [...]

  • http://www.jimcode.org Jim Rowe

    Hi, really useful but I cannot work out how to get the currency code for a specific order.

    I have…

    $order = new Mage_Sales_Model_Order();
    $incrementId = Mage::getSingleton(‘checkout/session’)->getLastRealOrderId();
    $order->loadByIncrementId($incrementId);

    and expected this to get my currency code…

    $order->getCurrencyCode();

    Any ideas?

    Thanks

  • http://www.jimcode.org Jim Rowe

    Thought I should answer my own question…

    $order->getOrderCurrencyCode();

  • http://www.currency.com.pk Dollar Rate

    Sorry, no idea Jim !

  • Bharat Paghadal

    hello,

    How can i display a multi currency like as below.

    Us Dollar : $23
    Euro : (eurosimbol)34
    Rs : Rs100

    how can i display this in product view page.