How to add Currency selector to Magento’s header

How to add Currency selector to Magento’s header

Since Magento has built in functionality for currencies, it shouldn’t be too hard to create custom currency selector and put it to the header. You might say this tutorial is for beginners, since it’s pretty much straightforward. You might have noticed the ”Currency Setup” tab in Magento’s Administration under “System->Configuration” menu. There you should select default site currency, and besides that, all currencies you want to support. Here’s a screenshot of that tab: How to add Currency selector to Magento’s header After that, you should go to “System->Manage Currency Rates” and set rates for currencies you’ve chosen before. You can use Webservicex to import currency rates from Webservicex service. Here’s how it looks like: And now, after you’re done with initial setup, let’s go further with modifications to make that output shows in the header. First thing you should do is to create a new template file and put it under “YOUR_PACKAGE/YOUR_THEME/template/currency/currency.phtml”. Put in this content:
getCurrencyCount() > 1): ?>
You can put in line #10 either $_name or $_code, depending what do you want to show in your currency selector. Here you can see how these changes affect to the selector. Next thing you should do is to tell Magento which template should be used for the selector. You should create “YOUR_PACKAGE/YOUR_THEME/layout/local.xml”, or just append the following content if you already have this file in your theme.


And finally, there’s one more thing you’ll need to do to make the template visible on frontend, Open “YOUR_PACKAGE/YOUR_THEME/template/page/html/header.phtml” (or create new file if there isn’t any) and add the following content:
getIsHomePage()): ?>

getLogoAlt() ?>

getChildHtml('topSearch') ?>

getWelcome() ?> getAdditionalHtml() ?>

getChildHtml('topLinks') ?> getChildHtml('store_language') ?> getChildHtml('custom_currency_selector') ?>
getChildHtml('topContainer'); ?>
getChildHtml('topMenu') ?>
After this, if you save everything, clear the cache and reload the page, you should see something like this: Note! By default, Magento is configured to show default currency selector if there is more than one currency set up. You can see that below: To disable default currency selector you need to add
to default handle in your layout.xml. Then, your local.xml would look like this:


I hope this helped someone, cheers! Info! Source URL:
  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
  • Youtube

leave a comment