Hello friends, today I will show you opencart auto detect currency according to visitor. Opencart is one of the best php based ecommerce platform for any type of shopping site and also my favourite ecommerce application. I am building ecommerce sites in opencart from 1 year. Today, I come with a special requirement in opencart. This requirement comes from my client. My client requirement is “When a guest user is visiting his site, the website whole curreny will automatically changed to guest user country currency.” For example if a user is visiting from US his/her currency will automatically changed in USD.

All the product value will converted into USD. Though opencart has an option to set default currency for whole site in admin portion(from setting menu), so by default all the product price will show according to default currency and in front end when a user will change curreny by clicking currecy icon at top position, he or she will show all product price with that curreny. But in this case the default currency set by admin also automatically changed if a user will visit from another country. This is an auto detect currency application in Opencart. Now come to the solution-



opencart auto detect currency

Step 1: Now open currency.php from “root_path/system/library/currency.php”. Copy this below code and paste it to currency.php at the end of any function.

Step 2: Change this function public function __construct($registry) in same file currency.php. Just comment you public function __construct($registry) function and paste below code:

Now your work opencart auto detect currency is done. Check your website. It will work fine. I did this in Opencart 1.5.4 version.

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
opencart auto detect currency according to visitor
Tagged on:
  • GRoc

    Thank you so much! It works in OC 2.0.2.0 🙂

  • José Mendes

    Hello,

    Thanks for sharing this info.

    My question is if it ‘s possible get the language from the browser instead by IP.