Display currency selection in header

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

Create a new phtml file (../template/<dirname>/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 ?>
        <?php endforeach; ?>
<script type="text/javascript">
function changeCurrency(sObject){
        setLocation('<?php echo $this->helper('directory/url')->getSwitchCurrencyUrl() ?>currency/'+sObject.value);
<?php endif; ?>

Now edit the page.xml file and add code of line into HEADER section:

type="directory/currency" name="currency_top" template="directory/currency-top.phtml"/>
Edit header.phtml file and add following code:

echo $this->getChildHtml('currency_top') ?>

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

Cheers, :)


Popular posts from this blog

Magento Reindexing problem - take too long time

Magento Navigation menu of CMS pages

Script for to remove the cache - Magento