Jump to content

Currency based on country Ip


Recommended Posts

Hi I want to show the currency in my store, based on the IP accessed.

 

In case if the store accessed from USA, product price will be shown in '$',  if it is accessed fomr europe the price must in 'Euro'. How to implement on this, anyone please hlep me,

 

Thnaks in advance.

Edited by thilip.xandy (see edit history)
Link to comment
Share on other sites

this can be accomplished the way:

 

back office-->preferences-->geolocation

 

enable geolocation

 

then

 

back office-->localization-->countries-->edit county(ies)

 

set the default currency

 

 

Warning: when geolocation is active, and IP can not be found, then PrestaShop will follow the behavior defined in geolocation.  There is an issue with those that want the IP that can not be determined to default to shop country.  This can result in lost sales.

 

I have passion for Geo Location, see these modules:

Geo Location by PrestaHeroes.com

 

Advanced Language |  Currency Detetion

Edited by El Patron (see edit history)
Link to comment
Share on other sites

Hi EI patron: 

                  First thanks a lot for your reply. Hope you understand what is my requirement, if not I clearly in brief.

 

my requirement just like a basic thing:

 

When site viewer views from USA the site currency set to US Doller. In case if the site visitor visit from europe the site currency set to euro this is my requirment.

 

how can I process for this. I'm new to prestashop development. kindly please help to come out from this, 

 

Thanks in advance. 

Link to comment
Share on other sites

  • 3 months later...

 

here is modified function classes/controller/FrontController.php

 

I've commented '//' out the 'reject' when IP not found, this will allow visitors whose IP address can not be resolved to use default country.

	protected function geolocationManagement($default_country)
	{
		if (!in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1')))
		{
			/* Check if Maxmind Database exists */
			if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
			{
				if (!isset($this->context->cookie->iso_code_country) || (isset($this->context->cookie->iso_code_country) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')))))
				{
					include_once(_PS_GEOIP_DIR_.'geoipcity.inc');

					$gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD);
					$record = geoip_record_by_addr($gi, Tools::getRemoteAddr());

					if (is_object($record))
					{
						if (!in_array(strtoupper($record->country_code), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && !FrontController::isInWhitelistForGeolocation())
						{
							if (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_)
								$this->restrictedCountry = true;
							elseif (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_)
								$this->context->smarty->assign(array(
									'restricted_country_mode' => true,
									'geolocation_country' => $record->country_name
								));
						}
						else
						{
							$has_been_set = !isset($this->context->cookie->iso_code_country);
							$this->context->cookie->iso_code_country = strtoupper($record->country_code);
						}
					}
				}

				if (isset($this->context->cookie->iso_code_country) && $this->context->cookie->iso_code_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country))
					$this->context->cookie->iso_code_country = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
				if (isset($this->context->cookie->iso_code_country) && ($id_country = Country::getByIso(strtoupper($this->context->cookie->iso_code_country))))
				{
					/* Update defaultCountry */
					if ($default_country->iso_code != $this->context->cookie->iso_code_country)
						$default_country = new Country($id_country);
					if (isset($has_been_set) && $has_been_set)
						$this->context->cookie->id_currency = (int)(Currency::getCurrencyInstance($default_country->id_currency ? (int)$default_country->id_currency : Configuration::get('PS_CURRENCY_DEFAULT'))->id);
					return $default_country;
				}
//				elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_ && !FrontController::isInWhitelistForGeolocation())
//					$this->restrictedCountry = true;
//				elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_ && !FrontController::isInWhitelistForGeolocation())
//					$this->context->smarty->assign(array(
//						'restricted_country_mode' => true,
//						'geolocation_country' => 'Undefined'
//					));
			}
			/* If not exists we disabled the geolocation feature */
			else
				Configuration::updateValue('PS_GEOLOCATION_ENABLED', 0);
		}
		return false;
	}

 

this can be accomplished from back office, see above.

 

back office-->preferences-->geolocation

 

enable geolocation

 

then

 

back office-->localization-->countries-->edit county(ies)

 

set the default currency

 

Ciao El Patron

 

I have the same need: only EUR for Europe; only DOLLAR for USA.
I enabled the geolocalization and set-up the default currency USD for the country USA.
It works but I would to show only the default currency without the possibility to change it.
How can I do it?

 

thanks

Angela

Link to comment
Share on other sites

you would disable module block concurrences

 

becauseof danger using geo localization, I created advanced ietf module

http://www.prestashop.com/forums/topic/349727-module-advanced-visitor-language-currency-localization-ietf/.

 

Ciao;

 

I'm seeing your modules;

 

there is also this: http://www.etiendas.co/en/34-geo-targeting-pro-price-by-country.html

 

I have 2 needs:

 

1 - A different price list for country in Euro 

2 - A different price list for USA in USD

 

For each country I have to show only the specific price list in the correct currency.

 

which is the better your module for my case?

 

Let me know.

thanks

Link to comment
Share on other sites

Ciao;

 

I'm seeing your modules;

 

there is also this: https://www.prestaheroes.com/prestashop-geo-localization-solutions/69-geo-targeting-pro-price-by-country.html

 

I have 2 needs:

 

1 - A different price list for country in Euro 

2 - A different price list for USA in USD

 

For each country I have to show only the specific price list in the correct currency.

 

which is the better your module for my case?

 

Let me know.

thanks

this module, very mature, never cause issue, my motto 'I test so you don't have to'. :)

https://www.prestaheroes.com/prestashop-geo-localization-solutions/69-geo-targeting-pro-price-by-country.html

Edited by El Patron (see edit history)
Link to comment
Share on other sites

this module, very mature, never cause issue, my motto 'I test so you don't have to'. :)

http://www.etiendas.co/en/34-geo-targeting-pro-price-by-country.html

 

So do you suggest this module: http://www.etiendas.co/en/34-geo-targeting-pro-price-by-country.html

instead of http://www.etiendas.co/en/59-advanced-visitor-language-currency-localization.html

for my case?

 

thanks

:)

Link to comment
Share on other sites

 

if you want to use 'specific price by country' then geo tarteting pro, this extends native ps geo localization (makes it work), you do not want to use native geo location as geolitecity.dat is about 85% accurate...and if not resolved IP it disallows shopping..geo targeting pro solves this issue.

 

the advacned ietf, is an additional module..for advanced language | currency detection.  note: when used with geo targeting pro, then the currency will be set in that module.

Edited by El Patron (see edit history)
  • Like 1
Link to comment
Share on other sites

if you want to use 'specific price by country' then geo tarteting pro, this extends native ps geo localization (makes it work), you do not want to use native geo location as geolitecity.dat is about 85% accurate...and if not resolved IP it disallows shopping..holy!

 

the advacned ietf, well it just rocks...and I think everyone should use it...jajajajaja...but I take my hobby seriously.

 

Hi El Patron,

 

I would to buy your module: 

GEO TARGETING PRO - PRICE BY COUNTRY

 

if I have probles; can you help me to setup it correctly?

 

Thanks

angela

Link to comment
Share on other sites

Hi El Patron,

 

I would to buy your module: 

GEO TARGETING PRO - PRICE BY COUNTRY

 

if I have probles; can you help me to setup it correctly?

 

Thanks

angela

 

Hi Angela, of course I would be most happy to help.  The module is very simple install with little configuration.

  • Like 1
Link to comment
Share on other sites

Hi I want to show the currency in my store, based on the IP accessed.

 

In case if the store accessed from USA, product price will be shown in '$',  if it is accessed fomr europe the price must in 'Euro'. How to implement on this, anyone please hlep me,

 

Thnaks in advance.

Hi,

 

I have using prestashop currency switcher module, using this i can map the currency with countries.

Like USD for US, pound for UK.

http://www.modulebazaar.com/en/prestashop-geoip-module.html

 

thanks,

Link to comment
Share on other sites

Hi,

 

I have using prestashop currency switcher module, using this i can map the currency with countries.

Like USD for US, pound for UK.

http://www.modulebazaar.com/en/prestashop-geoip-module.html

 

thanks,

 

I wrote new module, that works better in that we do not rely on IP.  the module uses http_accept_language.

 

http://www.prestashop.com/forums/topic/349727-module-advanced-visitor-language-currency-localization-ietf/

please see this link for front office demo and user guide to see how it works.

 

you may also note that I will double your purchase price if it's not the best module on the planet for visitor localization. :)

Link to comment
Share on other sites

I wrote new module, that works better in that we do not rely on IP.  the module uses http_accept_language.

 

http://www.prestashop.com/forums/topic/349727-module-advanced-visitor-language-currency-localization-ietf/

please see this link for front office demo and user guide to see how it works.

 

you may also note that I will double your purchase price if it's not the best module on the planet for visitor localization.

If i am having english and french in my site, how to add the english to US and french to london.

shall i add german from your module?

Link to comment
Share on other sites

If i am having english and french in my site, how to add the english to US and french to london.

shall i add german from your module?

 

the solution is using actual visitor information/preferences from http request to determine language, then we match the currency as set in native prestashop-->localization-->countries-->edit country-->set default currency.  T

 

you would not add German to module (this module is so accurate, that there is no configuration required.)  You would simply add German language to your shop, set Germany default currency as described above and sleep well at night.

Link to comment
Share on other sites

  • 1 month later...

Hi El Patron,

 

For the site I work on, we need to have specific language / specific currency / specific prices depending on where the user is.

 

We bought your module Geo Targeting Pro few months ago because it was apparently the best option (?).

 

Can you confirm it;s still the best way to go, or your new module is better for our needs ?

http://www.prestashop.com/forums/topic/349727-module-advanced-visitor-language-currency-localization-ietf/

 

Thanks to advise here.

 

G

Link to comment
Share on other sites

Hi El Patron,

 

For the site I work on, we need to have specific language / specific currency / specific prices depending on where the user is.

 

We bought your module Geo Targeting Pro few months ago because it was apparently the best option (?).

 

Can you confirm it;s still the best way to go, or your new module is better for our needs ?

http://www.prestashop.com/forums/topic/349727-module-advanced-visitor-language-currency-localization-ietf/

 

Thanks to advise here.

 

G

 

Howdy!

 

well geo targeting pro primary reason for existence if price by country(make sure you  have v.4.6)...secondary is marrying currency to country....

 

the issue with any 'ip' detection, is what to do with 'non-resolved' ip's...it uses shop default...this is issue I'm addressing now...release later...(note this will allow 'any' detect module to use default you choose, not shop default currency)

 

ietf will not be best choice (currency) for you right now, geo targeting will set currency to resolved country, ietf is called later and will not set currency as it's already set...note: ietf is for lang...secondary currency...so if you want best in class lang detect, then ietf is for you (anyone).

 

happy geoing...el

Link to comment
Share on other sites

Howdy!

 

well geo targeting pro primary reason for existence if price by country(make sure you  have v.4.6)...secondary is marrying currency to country....

 

the issue with any 'ip' detection, is what to do with 'non-resolved' ip's...it uses shop default...this is issue I'm addressing now...release later...(note this will allow 'any' detect module to use default you choose, not shop default currency)

 

ietf will not be best choice (currency) for you right now, geo targeting will set currency to resolved country, ietf is called later and will not set currency as it's already set...note: ietf is for lang...secondary currency...so if you want best in class lang detect, then ietf is for you (anyone).

 

happy geoing...el

 

Hey El Patron,

 

I checked the back-end and it says my version is 4.0 (see attached)

It doesnt automatically proposes me to update it...is there a newer version? Manual update ?

 

Cheers,

post-838972-0-09989000-1415008513_thumb.jpg

Link to comment
Share on other sites

Hey El Patron,

 

I checked the back-end and it says my version is 4.0 (see attached)

It doesnt automatically proposes me to update it...is there a newer version? Manual update ?

 

Cheers,

 

that version is good to go.

 

remind me of what you are trying to accomplish.

 

note: for currency you need to set each countries default currency (bo-->localization-->countries-->edit country-->set default currency) 

Link to comment
Share on other sites

that version is good to go.

 

remind me of what you are trying to accomplish.

 

note: for currency you need to set each countries default currency (bo-->localization-->countries-->edit country-->set default currency) 

I'd like the site visitor to be "country identified" by his IP, then depending on his IP country to setup the currency and prices accordingly.

 

Thanks!

Link to comment
Share on other sites

I'd like the site visitor to be "country identified" by his IP, then depending on his IP country to setup the currency and prices accordingly.

 

Thanks!

 

with geo targeting pro...

for currency:

back office-->localization-->countries-->edit a country-->set default currency

now currency is selected by country resolved by IP

 

for prices

back office-->catalog-->products-->edit a product-->prices-->add new specific price 'by country'

now visitors by country specific price is shown for this product.

 

that's it

Link to comment
Share on other sites

with geo targeting pro...

for currency:

back office-->localization-->countries-->edit a country-->set default currency

now currency is selected by country resolved by IP

 

for prices

back office-->catalog-->products-->edit a product-->prices-->add new specific price 'by country'

now visitors by country specific price is shown for this product.

 

that's it

Hi El Patron,

 

Thanks for the confirmation.

 

Do you know if it's possible to use the import / CSV function to import products with different prices for different countries ?

(in  the csv panel these fields are missing, making me think that it's not possible...)

 

Cheers,

G

Link to comment
Share on other sites

Hi El Patron,

 

Thanks for the confirmation.

 

Do you know if it's possible to use the import / CSV function to import products with different prices for different countries ?

(in  the csv panel these fields are missing, making me think that it's not possible...)

 

Cheers,

G

 

Hi, I am 'clueless' with csv capability, I suggest opening new topic on this subject to be best community review/reply.

Link to comment
Share on other sites

  • 1 month later...

with geo targeting pro...

for currency:

back office-->localization-->countries-->edit a country-->set default currency

now currency is selected by country resolved by IP

 

for prices

back office-->catalog-->products-->edit a product-->prices-->add new specific price 'by country'

now visitors by country specific price is shown for this product.

 

that's it

Hi El Patron,

 

We realized we have a currency formatting issue:

When using japanese Yens, we don't want to have for example 1925 yens, but it should e formatted to 1900 yens (kind of marketing rounding, it looks cleaner and usual for japanese clients...)

 

Because the default currency of the shop is euro, when we put specific price for japan we have to put them in euro...and with the exchange rate, we always get prices displayed in Yens that are too precise for us like 1925 yens, but we would like them to be rounded/formatted to 1900 yens.

 

I hope you can understand my issue and propose me an option ?

(I'd like to avoid to use Yen as the default store currency if possible...)

 

Many thanks,

G

Link to comment
Share on other sites

Hi El Patron,

 

We realized we have a currency formatting issue:

When using japanese Yens, we don't want to have for example 1925 yens, but it should e formatted to 1900 yens (kind of marketing rounding, it looks cleaner and usual for japanese clients...)

 

Because the default currency of the shop is euro, when we put specific price for japan we have to put them in euro...and with the exchange rate, we always get prices displayed in Yens that are too precise for us like 1925 yens, but we would like them to be rounded/formatted to 1900 yens.

 

I hope you can understand my issue and propose me an option ?

(I'd like to avoid to use Yen as the default store currency if possible...)

 

Many thanks,

G

 

I understand working in multi-currency and displaying can be a bit of a pain

 

you said:

 

(I'd like to avoid to use Yen as the default store currency if possible...)

 

I have module that allows you to have different front office default currency than back office: (and it is FREE module)

https://www.prestaheroes.com/prestashop-module/60-front-office-default-currency.html

 

when you visit my shop switch to yen, I use another of my modules to charm endings, so you will notice  all my yes are xx,500.  this done by Price Charming Module.

 

and one other module I had fun writing, Advanced IETF lang/currency detect,  it expands ps basic visitor browser lang detect so if lang jap it will set yen as currency..holy!

 

Please note, I am not pushing you to buy my geo modules, but it's an area I have some passion for and like to chat about.  Happy day, el.

Edited by El Patron (see edit history)
Link to comment
Share on other sites

I understand working in multi-currency and displaying can be a bit of a pain

 

you said:

 

(I'd like to avoid to use Yen as the default store currency if possible...)

 

I have module that allows you to have different front office default currency than back office:

http://etiendas.co/en/prestashop-module/60-front-office-default-currency.html

 

when you visit my shop switch to yen, I use another of my modules to charm endings, so you will notice  all my yes are xx,500.  this done by Price Charming Module.

 

and one other module I had fun writing, Advanced IETF lang/currency detect,  it expands ps basic visitor browser lang detect so if lang jap it will set yen as currency..holy!

 

Please note, I am not pushing you to buy my geo modules, but it's an area I have some passion for and like to chat about.  Happy day, el.

Hi El Patron,

 

Sounds like you have a module for each issue... :)

 

Topic is out of this thread now so I'll send you a pm.

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...