Welcome,
Guest
.
Please
login
or
register
.
Did you miss your
activation email
?
News:
Elxis 5.5 Calypso supports 2 factor authentication login with e-mail or SMS.
Home
Help
Login
Register
Elxis CMS Forum
»
Extensions
»
Modules
»
IOSR - local currency
« previous
next »
Print
Pages: [
1
]
Author
Topic: IOSR - local currency (Read 5047 times)
wieyoga
Jr. Member
Posts: 77
IOSR - local currency
«
on:
January 13, 2016, 02:54:45 »
Please advise how to display local currency based on visitor location
Logged
Online hotel reservation -
http://www.easyresv.com
datahell
Elxis Team
Hero Member
Posts: 10356
Re: IOSR - local currency
«
Reply #1 on:
January 13, 2016, 09:32:29 »
You can't detect visitor's country reliable. And even if you do so you don't know if he prefers to switch currency. For example I connect to the internet via a proxy server located in Germany but I live in Greece. Only if you use an "IP to country" API, or an IP to country database
like this
, provided by a third party then the detection could be good enough. From the moment you detect the correct country then you must have a table to assign the proper currency. When you find the currency you can switch currency like that:
$currency = 'EUR';
$eSession = eFactory::getSession();
$eSession->set('rescurrency', $currency);
This detection should not happen on each user click but only on his first visit on site. So you need an additional session check. After you switch the user you must refresh the page to see the new currency. Such code can be placed in your template's index.php file.
Full example
$eSession = eFactory::getSession();
$ok = $eSession->get('resautocurrency', 0);
if (!$ok) {
$country = something_to_detect_user_country();
if (($country == 'GR') || ($country == 'ES') || ($country == 'FR') || ($country == 'DE') || ($country == 'IT')) {
$currency = 'EUR';
} else if ($country == 'RU') {
$currency = 'RUB';
} else if ($country == 'GB') {
$currency = 'GBP';
} else if ($country == 'US') {
$currency = 'USD';
} else {
$currency = 'EUR';
}
$eSession->set('rescurrency', $currency);
$eSession->set('resautocurrency', 1);
$url = eFactory::getURI()->getRealUriString();
eFactory::getElxis()->redirect($url);
}
«
Last Edit: January 13, 2016, 09:38:29 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
Print
Pages: [
1
]
« previous
next »
Elxis CMS Forum
»
Extensions
»
Modules
»
IOSR - local currency