Reputation: 61
I know how to get the country where the user is accessing my site based on IP Address. Now I want to set the currency automatically based on the IP Address. Where or What module in Opencart should I change?
Upvotes: 0
Views: 1863
Reputation: 16065
According to the source code in system/library/currency.php
you can call:
$this->currency->set('GBP');
anywhere in your controller. This is also called whenever user changes the currency by clicking on the currency sign in the header - as you can check in catalog/controller/module/currency.php
:
if (isset($this->request->post['currency_code'])) {
$this->currency->set($this->request->post['currency_code']);
// ...
}
Unfortunately there is no check whether you are trying to set the existing (defined, registered) currency code or not so make sure you are using only those codes that are present in your DB (i.e. created via administration).
Upvotes: 1