Home » Magento

Magento: Show Currency Selector in header

25 August 2010 3,136 views Popularity: 7% Share/Bookmark

email

Here, I will show you how you can change the location of currency selector to header in Magento.

By default, the currency selector is displayed in the left sidebar. Here, I will show you how you can show it in header just below the language selector.

Create a new phtml file (template/directory/currency-top.phtml) and write the following code in it :-

<?php if($this->getCurrencyCount()>1): ?>
<div class="box language-switcher" style="margin-left:15px">
    <label for="select-language">Your Currency: </label>
        <select name="currency" onchange="changeCurrency(this)">
        <?php foreach ($this->getCurrencies() as $_code => $_name): ?>
            <option value="<?php echo $_code ?>"<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected="selected"<?php endif; ?>>
                <?php echo $_name ?> - <?php echo $_code ?>
            </option>
        <?php endforeach; ?>
        </select>
</div>
<script type="text/javascript">
//<![CDATA[
function changeCurrency(sObject){
    if(sObject.value){
        setLocation('<?php echo $this->helper('directory/url')->getSwitchCurrencyUrl() ?>currency/'+sObject.value);
    }
}
//]]>
</script>
<?php endif; ?>

Add currency_top block after store_language block inside header block of page.xml present around line #66 :-

<block type="page/html_header" name="header" as="header">
	<block type="page/template_links" name="top.links" as="topLinks"/>
	<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
	<block type="directory/currency" name="currency_top" template="directory/currency-top.phtml"/>
	<block type="core/text_list" name="top.menu" as="topMenu"/>
</block>

Add getChildHtml(‘currency_top’) below getChildHtml(‘store_language’) in template/page/html/header.phtml like below :-

<?php echo $this->getChildHtml('store_language') ?>
<?php echo $this->getChildHtml('currency_top') ?>

That’s all. Now, you will be able to see currency selector in the header of your site.

Hope this helps. Thanks.

Related posts:

  1. Magento: Showing Store Selector / Switcher in header and footer
  2. Magento: Show Currency Selector in right sidebar
  3. Magento: Convert Price from Current Currency to Base Currency and vice-versa
  4. Magento: How to get Currency Rates?
  5. Magento: How to call block directly from phtml file without defining in layout?
  6. Magento: How to call static block from template file?
  7. Magento: Setup multiple currency shop
  8. Magento: How to change Currency symbol by Model Override ?
  9. Magento: How to change Currency symbol ?
  10. Javascript: Show/Hide HTML elements
  • http://www.biztechconsultancy.com/magento-theme-design.htm Magento Theme Design

    Nice! Thanks for so good stuff. Keep it up.

  • http://www.magentonews.co.uk/magento-tips/magento-show-currency-selector-in-header-2/ Magento: Show Currency Selector in header | Magento News

    [...] Mukesh Chapagain's Blog | Post Magento: Show Currency Selector in header Copyright © 2010 This feed is for personal, non-commercial use only. The use of this feed on [...]

  • Dinker

    great bro…….

  • Asdasd

    Amazing! You can’t imagine how much I appreciate this! I’ve been looking how to display currency switcher all over the Internet. Thanks a lot!

  • Rahul

    hi i did according to you but it is not shown in header.. please help me how can i show currency selector in header

  • http://www.voodish.co.uk/articles/currency-drop-down-selector-in-header-magento/ Currency drop down selector in header, Magento, Voodish Articles.

    [...] thanks to Mukesh for [...]

  • Daivu

    sorry but in my header not showing… language selector… plz help