Thursday, 14 June 2012

How to change the currency selector with flag in magento

1. You need to prepare a flag list (images).
2. Upload flag list to root/media/flag directory
3. Rename flags to currency’s code (EX: US Dollar -> usd.jpg, Euro -> eur.jpg, Hong Kong Dollar -> hkd.jpg...)
4. In the template file: app/design/frontend/default/your_theme/template/directory/currency.phtml (or app/design/frontend/base/default/template/directory/currency.phtml), change code to:

<ul>
 
<?php foreach ($this->getCurrencies() as $_code => $_name): ?>
 
<li>
          <
a href="<?php echo $this->getSwitchCurrencyUrl($_code) ?>" onclick="setLocation(this.value);">
                   <
img src="<?php echo Mage::getBaseUrl('media').'flag/'.$_code.'.jpg'; ?>" title="<?php echo $_name ?> - <?php echo $_code ?>" alt="<?php echo $_name ?> - <?php echo $_code ?>" width="20" height="20" />
        </
a>
      </
li>
          
        
<?php endforeach; ?>
        
</ul>

8 comments:

  1. Thats very good post.My probelem Solved.

    ReplyDelete
  2. try a premium extension by FMEextensions which adds a popup in the footer and you can select the Currency and Language http://www.fmeextensions.com/magento-geo-ip-default-language-currency.html

    ReplyDelete
  3. For many stores will be better to set auto currency switcher. Here is one https://www.magestyapps.com/magento-extensions/geoip-store-switcher.html

    ReplyDelete
  4. Thanks Ali,

    Its really very helpful.

    thanks once agian.

    ReplyDelete
  5. Hi,

    Thanks for sharing this code working fine on my website with flag symbol https://www.pacetech.com/

    Regards

    ReplyDelete
  6. I do agree with all the ideas you have presented in your post. They’re really convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a little from next time?..Keep this great work
    magento development company in bangalore 

    ReplyDelete
  7. thanks for your help ...but i am not able to display USA flag .............

    ReplyDelete
  8. IS THIS CODE WORKING IN MAGENTO 2.1.9?

    ReplyDelete

Note: only a member of this blog may post a comment.