Tuesday 30 April 2013

currency changer in header magento

1-create local.xml file



<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="header">
            <block type="directory/currency" name="custom_currency_selector" template="currency/currency.phtml"/>
        </reference>
    </default>
</layout>

and place it in your   app/design/frontend/package/theam/layout/    folder









currency.phtml  should be in your  app/design/frontend/package/theam/template/currency/


<?php if($this->getCurrencyCount() > 1): ?>
<div class="form-language">
    <label for="custom-currency-selector"><?php echo $this->__('Your Currency:') ?></label>
    <select onchange="window.location.href=this.value" name="custom-currency-selector" id="custom-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 $_code ?>
        </option>
        <?php endforeach; ?>
    </select>
</div>
<?php endif; ?>







header.phtml which path is       app/design/frontend/package/theam/template/page/html/      already contain code  given blow if it is not there then add it in your

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





and last thig go to        admin->system->configuration       select your       current configuration scope
go to      Currency Setup select your allowed currency   and make sure use default should not be checked















No comments: