How to add currency selector in header of Magento
In magento by default currency selector renders in right side bar. To show it in the header is not a hard job. This blog will let you know about moving it to header of magento.
First of all setup your desired currencies for your store from magento admin. Now create a new template file and put it under following directory structure :
app/design/frontend/your_package/your_theme/template/currency/currency.phtml
[php]
<?php if($this->getCurrencyCount() > 1): ?>
<div class="form-language">
<label for="currency-selector"><?php echo $this->__(Currency’) ?></label>
<select onchange="window.location.href=this.value" name="currency-selector" id="currency-selector">
<?php foreach ($this->getCurrencies() as $code => $name): ?>
<option value="<?php echo $this->getSwitchCurrencyUrl($code)?>"
<?php if($code == $this->getCurrentCurrencyCode()): ?>
selected="selected"
<?php endif; ?>>
<?php echo $name ?>
</option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
[/php]
Now create following file so that magento use this file to render currency selector.
app/design/frontend/your_package/your_theme/layout/local.xml
[php]
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="header">
<block type="directory/currency" name="my_currency_selector" template="currency/currency.phtml"/>
</reference>
</default>
</layout>
[/php]
Now open app/design/frontend/your_package/your_theme/page/html/header.phtml and add following line :
[php]
<?php echo $this->getChildHtml(‘my_currency_selector’) ?>
[/php]
That’s it. Hope this will help you.
Regards,
Amatya Trivedi
amatya@intelligrape.com
Please don’t copy and paste the codes from other sites…please use your own cods
this is good work thank you