Jump to content
tomerg3

[MODULE] Location Detection - Detect the location of a visitor using their IP Address and automatically redirect them to the matching language

Recommended Posts

This Module uses a local Database table to determine the location of a visitor based on their IP Address.

It automatically redirects them to the matching language (IE www.yourwebsite.com/lang-fr).

It only works if you have that language installed in Prestashop.

To see it in action, visit http://www.presto-changeo.com/

This module works on PS 1.1, 1.2 and 1.3, for 1.4+ see http://www.prestashop.com/forums/viewthread/105240/

http://www.presto-changeo.com/en/7-prestashop-free-modules

Version 1.1 has just been released including:

* Better language detection.
* Browser language detection.
* Matching Currency Selection.
* Easier Installation.

Version 1.2 was just released, it includes:

* Ability to edit the Country to Language and Currency codes
* Ability to disable the currency detection / selection
* Fix to some language codes
* Compatibility with Prestashop 1.1
* Better handling of language selection

V 1.3 was just released, it fixes a bug that was causing trouble when cookies were not enabled
It is highly recommended to upgrade to this version since the problem may have affected Search Engines

V 1.3.1 was just released, it fixes a bug the was causing an infinite redirect when both the location of the user, and the default browser language were different from the prestashop default language

It is recommended to upgrade to this version (1.3.1)

V1.4 has been released, it includes:

* Ability to choose a default language and currency (when the customer's local language is not available in your shop).
* Link a language to a currency (so when a customer clicks on a language flag, the currency changes too).
* Bug fix for currency detection (wasn't working if there was only 1 language)

V1.4.2 released, bug fix for linking language to currency in IE and safari, and now also works on page load.

V1.5 released, redirection bug fix when no cookies are present, fix for notices on first install, updated IP -> Country database

V1.5.1 released, it includes a fix for the language detection, and does a double redirect to avoid having ?redirected in the address

P.S
I have put a lot of hours in to this, so please consider a donation.

  • Like 3

Share this post


Link to post
Share on other sites

Hi Tomerg3,

ThanX for your contribution...I downloaded the module but there are no instructions on how to upload, in particulr the install.sql

regards

Dan

Share this post


Link to post
Share on other sites
Hi Tomerg3,

ThanX for your contribution...I downloaded the module but there are no instructions on how to upload, in particulr the install.sql

regards

Dan


When you click on the "install" button in the Modules tab in the backoffice, the database gets installed automatically.

Once that is done, click "configure" next to the module (it's under Tools) and you will see the instructions on how to hook it up to Prestashop (you need to copy a few lines to /header.php).

Share this post


Link to post
Share on other sites

This is a great module. A great benefit for international company. We will use it on our production site when it is live.

Thank you for sharing.

Share this post


Link to post
Share on other sites

This is a great idea to install something like this for international site. I emailed this link to all of the Japanese forum members.

Thanks for sharing.

One question: What about a Japanese lives in the U.S and has Japanese ad default language install. What language will this person see?

Share this post


Link to post
Share on other sites
This is a great idea to install something like this for international site. I emailed this link to all of the Japanese forum members.

Thanks for sharing.

One question: What about a Japanese lives in the U.S and has Japanese ad default language install. What language will this person see?


You're welcome....

Right now they will see the default language, I will add that feature in the next version I release.

Share this post


Link to post
Share on other sites

I love it. This is a must have module for international site. Thank you for sharing.

Share this post


Link to post
Share on other sites
I love it. This is a must have module for international site. Thank you for sharing.


Thanks!

The following are also very useful for International sites (or those that want to become one)

Google Sitemap fix - http://www.prestashop.com/forums/viewthread/35047/
Prevent page title duplication for multiple languages - http://www.prestashop.com/forums/viewthread/35135/
Website Translator - http://www.prestashop.com/forums/viewthread/34524/

Share this post


Link to post
Share on other sites

Hi tommer ,

great module ,thanks..One question: what web host would you recommend in the US

Ken

Share this post


Link to post
Share on other sites
Hi tommer ,

great module ,thanks..One question: what web host would you recommend in the US

Ken


I use BlueHost for all the sites I own / manage.

They have 24/7 live support and offer good services.

They only offer shared hosting, so if your site is getting huge traffic, you may want to get a dedicated service, however I had no problems hosting http://www.TennisLessons.com and http://www.MathLessons.com on the same account, and they were getting around 30,000 visitors at the peak of the season.

You can Signup using http://www.bluehost.com/track/tomer

Share this post


Link to post
Share on other sites
Hi.Thanks for this module.
Quick question..how do we know it works?:-)


If you want to test it yourself, set the default shop language to something other than the country you are in.
I.E if you are in France and have French and English, set your default language in Prestashop to English.
Clean your cookies and type your domain in a new browser, it will come up in French...

Share this post


Link to post
Share on other sites

Hi Tomerg3

Great idea but I think it does not work on my site located in Denmark yet.

Suggestion: may be you can add an option that the language can link to a currency. For example Danish is linked to DKK Swedish linked to SEK

You can check rocky's thread

http://www.prestashop.com/forums/viewthread/17877/modules/solved_i_want_to_move_the_blockcurrency_module

Cheers & ThanX

Dan

:-)

Share this post


Link to post
Share on other sites
Hi Tomerg3

Great idea but I think it does not work on my site located in Denmark yet.

Suggestion: may be you can add an option that the language can link to a currency. For example Danish is linked to DKK Swedish linked to SEK

You can check rocky's thread

http://www.prestashop.com/forums/viewthread/17877/modules/solved_i_want_to_move_the_blockcurrency_module

Cheers & ThanX

Dan

:-)


The IP to Country detection is not 100% correct, it may be that the IP you were testing from was identified incorrectly.
You can PM me your site with some info and I will take a look.

I like your suggestion, I will add it to the next version.

Thanks!

Share this post


Link to post
Share on other sites

Version 1.1 has just been released including:

* Better language detection.
* Browser language detection.
* Matching Currency Selection.
* Easier Installation.

P.S
I have put a lot of hours in to this, so please consider a donation.

Share this post


Link to post
Share on other sites

I am not using this module. My shop only uses English. But this module is a great module for international site. If I were using this module, I won't mind to make a donation.

Share this post


Link to post
Share on other sites

Hi Tomerg3,

Great effort with the Location identifier!!!

You were lighting quick to implement my suggestion on the currencies.

I have installed V1.1 and made the changes to the header.php ; cleared the coockies and it does not seem to work on a test site I have at:

http://www.jmaya.com/JMSHOP/

I am located in Denmark - changed my default currency from DKK to NOK and default language to Norweigen. I then used

http://anonymouse.org/anonwww.html

to simulate an unknowen IP address and it does not seem to identify the IPs

Am I missing something?

ThanX again for your efforts

Regards

Dan

Share this post


Link to post
Share on other sites

Hi Tomberg.

have installed the updated version from 1.0 and it was a breeze. Nice work on the code for the header:-)

Well all appears to be working and I will keep you updated on how things go, but for now I can only test it myself by changing the default language, but I will begin to ask my customers how they reach the website.

As for the suggestion of a donation from another poster, well I will offer you a discount on a product in my shop. We are here to do business right??

If you can get your head around doing a one-page checkout at a fair price you will do very well with that type of module.

All the best..

Share this post


Link to post
Share on other sites
Hi Tomerg3,

Great effort with the Location identifier!!!

You were lighting quick to implement my suggestion on the currencies.

I have installed V1.1 and made the changes to the header.php ; cleared the coockies and it does not seem to work on a test site I have at:

http://www.jmaya.com/JMSHOP/

I am located in Denmark - changed my default currency from DKK to NOK and default language to Norweigen. I then used

http://anonymouse.org/anonwww.html

to simulate an unknowen IP address and it does not seem to identify the IPs

Am I missing something?

ThanX again for your efforts

Regards

Dan


I'm not sure where the ip you get from anonymouse.org is located, if it's not in one of the countries that you have a Prestashop translation for, then your site will open in the default language.

If you are in Denmark, and you set the default language and currency to something else, then you should be able to login from your own computer and see it in action.

Keep in mind, this module is only going to redirect to another language the first time you visit the site, so cache and cookies should be cleared (or use private mode in IE8).

It was working fine in my testing, but there is a chance there's a bug somewhere in there, I'll be more than happy to get to the bottom of it, since I like to have my modules 100% working.

Also, if you have livezilla running on your site, you can see that the users get redirected to their language page right after they land on your site.

Share this post


Link to post
Share on other sites
Hi Tomberg.

have installed the updated version from 1.0 and it was a breeze. Nice work on the code for the header:-)


Thanks!

Well all appears to be working and I will keep you updated on how things go, but for now I can only test it myself by changing the default language, but I will begin to ask my customers how they reach the website.

Please do.

As for the suggestion of a donation from another poster, well I will offer you a discount on a product in my shop. We are here to do business right??

While I appreciate the offer (it's more than other people have offered), we're not on the same continent, so it's not going to be much help.
Even a $5 donation would be great, not so much for the money, but just to show appreciation of the product


If you can get your head around doing a one-page checkout at a fair price you will do very well with that type of module.

I may do that after the "Occasion Reminder" module I'm working on.

Share this post


Link to post
Share on other sites

Hi again,

Located in Denmark and tested on Firefox, cleared all coockies set default language and currency to Norway. when I go in to the shop I get default language and currency. When I in via anonymouse.org (which should give me the default currency) I get language-English and currency-Norway.

Tried both "IP first" & "Browser first" and get the same result.

I have installed V1.1 and made the changes to the header.php. Am I missing an instalation action with the tables or something else?

Can understad that you want to get some appreciation for your work - GREAT EFFORT!!!. Will definately make a donation if it works for me with no bugs.

ThanX

Dan

Share this post


Link to post
Share on other sites

OK, so here's the problem, Prestashop uses the country iso code for Denmark (DK), but in fact the language is Danish which uses the language code DA.
I was defining the code for Denmark as DA, which was not getting picked up.

To fix this, edit /modules/locationdetection/locationdetection.php line 112 and change "da" to "dk" (keep it lowercase).

I was thinking about printing the language mapping table (which is hard coded in the file), or even making that editable from the BO, but since this a free module it is not high on my priority list.

Share this post


Link to post
Share on other sites

Great !!! it seems like it is working.

I checked other language codes like Swedish and Norwegian. They too had to be changed so it may be that other language codes need to be modified in the same manner.

Is it also compatible with PS 1.1 ?



:-)

Share this post


Link to post
Share on other sites
Great !!! it seems like it is working.

I checked other language codes like Swedish and Norwegian. They too had to be changed so it may be that other language codes need to be modified in the same manner.

Is it also compatible with PS 1.1 ?



:-)


Glad to hear it's working
I just noticed the differences in other languages too.
I will fix those for my next release (probably sometime next week), which will also be compatible with Prestashop 1.1

Share this post


Link to post
Share on other sites

That is correct, in the next version it will be fixed and there will be an option from the backoffice to edit the language mapping table.


It is a bit problematic with language codes.

In presta shop danish language is DK

ISO is dan or da

http://www.loc.gov/standards/iso639-2/php/code_list.php

I assume that other languages and currencies may have the same problem

Share this post


Link to post
Share on other sites

Hi Tomerg,

Another remark after testing.

My defauld currency and language are dkk and dk. I must keep the default currency dkk cause all other currencies are calculated according to the exchange rate related to my local currency.

Would like to have EURO and english for all "non identfied" IPs (not my defeult currency case that has to be local).

If you still have the power and it is not too complicated leave an option in the back office to choose "landing default" currency and language. Other wise better limit the module to language only.

Share this post


Link to post
Share on other sites

Version 1.2 was just released, it includes:

* Ability to edit the Country to Language and Currency codes
* Ability to disable the currency detection / selection
* Fix to some language codes
* Compatibility with Prestashop 1.1
* Better handling of language selection

Share this post


Link to post
Share on other sites

Hi Tomerg,

Installed V1.2 and all the improvment you mention are working.

Would it be difficult to add to the "Location Detection Options" default currency and language? Then the module would be perfect.

If PS defaults are used IPs with currencies and languages not defined in BO will end up in local language and currencies. Because of exchange rate conciderations and local currency calculations it is difficult to to change the default currency to non local.

Hope you understand my explanation...

ThanX and have a nice weekend

Dan

Share this post


Link to post
Share on other sites

Sorry for the unclear explenation.

My default language and currency on my shop is DK and DKK. I also have Norwegian and Swedish languages and currencies installed. Location detection works fine for these countries.

If someone with an IP from a differnet country enteres the shop I would like the language to be English and the currency to be EUR (Euro). For that I would need to change my PS default language and currency to English and EUR.

If I change the default language to English, everything works well.

If I change the default currency to EUR all exchange rates will be related to Euro. All products were entered to PS in DKK as default currency so prices are displayed with wrong values.

I have tested it in my test shop. Changed default currency value EUR, updated exchange rates and prices were displayed wrong.

If the problem is not clear, I would be happy to make another attempt in explaining. ;-)

Regards

Dan

Share this post


Link to post
Share on other sites
Sorry for the unclear explenation.

My default language and currency on my shop is DK and DKK. I also have Norwegian and Swedish languages and currencies installed. Location detection works fine for these countries.

If someone with an IP from a differnet country enteres the shop I would like the language to be English and the currency to be EUR (Euro). For that I would need to change my PS default language and currency to English and EUR.

If I change the default language to English, everything works well.

If I change the default currency to EUR all exchange rates will be related to Euro. All products were entered to PS in DKK as default currency so prices are displayed with wrong values.

I have tested it in my test shop. Changed default currency value EUR, updated exchange rates and prices were displayed wrong.

If the problem is not clear, I would be happy to make another attempt in explaining. ;-)

Regards

Dan


I think I understand what you mean now.
I may add a default language and currency for those case in the future.
In the meantime, you can change it from the BO module configuration, by changing the language and currency codes for all the countries you want to your preferred default.

Share this post


Link to post
Share on other sites

V 1.3 was just released, it fixes a bug that was causing trouble when cookies were not enabled
It is highly recommended to upgrade to this version since the problem may have affected Search Engines

Share this post


Link to post
Share on other sites

V 1.3.1 was just released, it fixes a bug the was causing an infinite redirect when both the location of the user, and the default browser language were different from the prestashop default language

It is recommended to upgrade to this version

Share this post


Link to post
Share on other sites

Hi Tomerg3

ThanX for the fix. Is there any chance that 'Location Detection' will have it's own default language and currency?

:-) Dan

Share this post


Link to post
Share on other sites
Hi Tomerg3

ThanX for the fix. Is there any chance that 'Location Detection' will have it's own default language and currency?

:-) Dan


I'm not sure I understand your request, the prestashop defaults are used, why have another set of defaults?

Share this post


Link to post
Share on other sites

Hi Tomerg,

I am in Denmark. My default language and currency are Danish & DKK. I have Swedish & Norwegian languages and currencies in my PS. I would like to have it so that if the shop is entered from any other country IP than Denmark Sweden or Norway, the language will be English and currency will be Euro.

Changing the PS defaults to English & Euro will creat other difficulties.

Hope it is clear. If not please let me know and I will try agin

ThanX & regards

Dan

Share this post


Link to post
Share on other sites
Hi Tomerg,

I am in Denmark. My default language and currency are Danish & DKK. I have Swedish & Norwegian languages and currencies in my PS. I would like to have it so that if the shop is entered from any other country IP than Denmark Sweden or Norway, the language will be English and currency will be Euro.

Changing the PS defaults to English & Euro will creat other difficulties.

Hope it is clear. If not please let me know and I will try agin

ThanX & regards

Dan


You can do that now.

In the form inside the module you can change the default language and currency for each country the module can detect.

All you need to do is change all of them to EN and EUR

Share this post


Link to post
Share on other sites

Wawooo OK great, will do that.

Sending you a small donation to show my apriciation.

ThanX again

:coolsmile:

Share this post


Link to post
Share on other sites
Wawooo OK great, will do that.

Sending you a small donation to show my apriciation.

ThanX again

:coolsmile:


Thanks!

It's a very nice gesture, I wish there were more of those gestures going around the forum.

There are a few other people here that contribute so much to the community (I.E rocky) and see a donation rate of less then 1/1000

Share this post


Link to post
Share on other sites

Hello. I'm from Poland.
This extension don't work for me :\
I change header.php, I set detect and redirect coutry and currency per language browser.

It's work like before, only languge is change.

I have two languages POLISH as deafult with deafult currency PLN and ITALY with currency EUR.
on site bella-elle.eu

Can u tell me why ?

Share this post


Link to post
Share on other sites

Hi Tomer,

Same for me, the currency bit does not work. I tried changing the tabels as you suggested but still I get the default currency.

:-) Cheers

Share this post


Link to post
Share on other sites

I was a little paranoid about search engines being affected by this module and I went a little too far :)

I have just released V 1.3.2 on my site, it takes care of this issue, and also adds another verification layer to ensure search engines are not affected by the module.

Thanks for letting me know about it.

Share this post


Link to post
Share on other sites
I was a little paranoid about search engines being affected by this module and I went a little too far :)

I have just released V 1.3.2 on my site, it takes care of this issue, and also adds another verification layer to ensure search engines are not affected by the module.

Thanks for letting me know about it.



STILL NOT WORK, I UPDATE on bella-elle.eu. Any sugestion ?

Share this post


Link to post
Share on other sites

Does the location detection part work?

If not, than maybe it's not installed properly...

Share this post


Link to post
Share on other sites

Hi Tomer,

I think my original suggestion of making a defulat currency for the module rather than using PS defualt currency will solv some problems.

:roll: Regards

Share this post


Link to post
Share on other sites
Does the location detection part work?

If not, than maybe it's not installed properly...


Location detection work. But not with currency.

Share this post


Link to post
Share on other sites

Thank you Tomer for all your contributions:)
I must say this module work perfect.

What I would like is an option to turn of the automatic part for ip-location or browser-language and just let the flags change the language and currency combined.

Why?
I redirect my customer from:
store.com > store.com/lang-en/
store.se > store.com/lang-se/
store.dk > store.com/lang-dk/ (...as is the same as clicking a flag-icon)

I would like those links/flags to change the currency as well ...regardless what country he/she is located in:
store.com > store.com/lang-en/ with currency $
store.se > store.com/lang-se/ with currency SEK
store.dk > store.com/lang-dk/ with currency DKK

Do you think you would be able to help us with that Tomer?


I just donated a small amount of $10 to you Tomer and I encourages the rest of you in the forum to do the same!

Thanks:)

Share this post


Link to post
Share on other sites

I will try to add that feature by the end of the week.

Thanks for the donation!

Share this post


Link to post
Share on other sites

Hi Tomer,

Any chance for default currency in the module itself?

ThanX again for all your contributions.

I do agree with PDN regarding the contributions for this free module and have donated myself $10

Cheers :-)

Share this post


Link to post
Share on other sites
Hi Tomer,

Any chance for default currency in the module itself?

ThanX again for all your contributions.

I do agree with PDN regarding the contributions for this free module and have donated myself $10

Cheers :-)


I'll add this one as well.

Share this post


Link to post
Share on other sites

Tomer... U R my hero

ThanX again (HAMON TODA)

Share this post


Link to post
Share on other sites

Thanks Tomer.. If you pull this off by the end of the week you can expect some more donation from me:)

Thanks again

Share this post


Link to post
Share on other sites

Just wanted to update the thread, I have been very busy lately with my Attribute Wizard Pro module, I did not forget about his one, and will try to get to it as soon as I can.

Share this post


Link to post
Share on other sites

Thanks for the update. Looking forward to it:)

Share this post


Link to post
Share on other sites

V1.4 has been released, it includes:

* Ability to choose a default language and currency (when the customer's local language is not available in your shop).
* Link a language to a currency (so when a customer clicks on a language flag, the currency changes too).
* Bug fix for currency detection (wasn't working if there was only 1 language)

Share this post


Link to post
Share on other sites

Thank you Tomer for all your efforts

:-)

Share this post


Link to post
Share on other sites

Yea:) Thank you so much Tomer!

I´m having a small problem. Everything works great on the frontpage.. Language/flag links to currency great but when I´m in a sub-category the language don´t change with the flag, only the currency? Any idée?

Share this post


Link to post
Share on other sites
Yea:) Thank you so much Tomer!

I´m having a small problem. Everything works great on the frontpage.. Language/flag links to currency great but when I´m in a sub-category the language don´t change with the flag, only the currency? Any idée?


PS version?

Share this post


Link to post
Share on other sites
Version 1.2.5


I think it may be related to your theme, since it works fine on my test server.

Anyone else experience a similar problem?

Share this post


Link to post
Share on other sites
Version 1.2.5


I think it may be related to your theme, since it works fine on my test server.

Anyone else experience a similar problem?




Bambi!
Would you be so kind and test this?

Test the module with the following "Location Detection Options" and se if your language change in your sub-categories:

Language Redirect: inactive
Options: doesn´t matter
Currency Redirect: inactive
Language & Currency Link: avtive

Share this post


Link to post
Share on other sites

Forgett it:) after a lot of research it looks like it´s my theme that causing the problem. I let you know

Share this post


Link to post
Share on other sites

Hi again,

We are about to go live but I can´t figure this out. I have tried to contact the theme creator without any luck:(

As I have mention before, everthing works great on the frontpage and also on the order page, "specials page" and "top sellers page" etc. The language and currency change when I click the flags (I don´t have any automatic redirection on) but when I click the flag in a sub-category (product sub-category) only the currency change?

Do anyone have any idea how to fix this? Or maby what files to look in? It would be much appreciated.

Share this post


Link to post
Share on other sites

Hi,

I am using PS with no theme but and have a problem with Location Detection.

Had to disable Language & Currency Link (inactive) cause language couldn't be changed.

:bug:

Share this post


Link to post
Share on other sites

I upgraded to the new version and I've found that when I want to change language in the FOR does not allow it, and I had a request and I get reflected either in the client area or in the BO (with virtual POS module).

Share this post


Link to post
Share on other sites
Hi,

I am using PS with no theme but and have a problem with Location Detection.

Had to disable Language & Currency Link (inactive) cause language couldn't be changed.

:bug:



Hi bambi,

What version do you use? Do you have the exact problem as I have? (see my previous post)

Share this post


Link to post
Share on other sites
Hi,

I am using PS with no theme but and have a problem with Location Detection.

Had to disable Language & Currency Link (inactive) cause language couldn't be changed.

:bug:



Hi bambi,

What version do you use? Do you have the exact problem as I have? (see my previous post)


Hi PDN,

I am using PS 1.2.5

My problem is that when Language & Currency Link is active, it is impossible to change languages. The buttons just freez.

Share this post


Link to post
Share on other sites

bambi, Do you have that problem on the entire site or just in the sub-category like me?

Share this post


Link to post
Share on other sites
bambi, Do you have that problem on the entire site or just in the sub-category like me?


The problem exsists in the entire site

Share this post


Link to post
Share on other sites

For some reason I was not getting notifications about the new replies here.

I have just released V1.4.1, it should take care of the language change problem.

Let me know if there are any other problems.

Share this post


Link to post
Share on other sites
For some reason I was not getting notifications about the new replies here.

I have just released V1.4.1, it should take care of the language change problem.

Let me know if there are any other problems.


I still have the same problem in my sub-categorys. My language wont change there.

Share this post


Link to post
Share on other sites

Tomer found the cause to my problem. I had messed up friendly urls in my .htaccess (regenerate and all should be good)
The module is working fine for me and I would like to thank Tomer for building this module... Good work!

Share this post


Link to post
Share on other sites

Hi

Just found out that when location detection is installed, the decimal fractions in my shop don't add up right.

I am using V1.4 on PS 1.2.5

Am I the only one?

Cheers

:-)

Share this post


Link to post
Share on other sites

Is everything normal when you disable my module, I can't imagine my module causing this issue.

Share this post


Link to post
Share on other sites

Hi Tomer

After uninstalling the module the calculation problem dissapeared. Now I have upgraded to your last version and it seems to be working well, also the flags.

Thank you so much for this module!

Share this post


Link to post
Share on other sites

V1.4.2 released, bug fix for linking language to currency in IE and safari, and now also works on page load.

Share this post


Link to post
Share on other sites
V1.4.2 released, bug fix for linking language to currency in IE and safari, and now also works on page load.


Great work Tomer! No need for me to update right? :)

Share this post


Link to post
Share on other sites
V1.4.2 released, bug fix for linking language to currency in IE and safari, and now also works on page load.


Great work Tomer! No need for me to update right? :)


no, you are all set

Share this post


Link to post
Share on other sites

Hi Tomerg,

Thank u for a great module...downloaded today. I have different shipping costs to different countries. Is it possible the module will assign the country also so that the respective shipping fees will be displayed while customer is shopping? now he only gets the default carrier (local post - cheap fees). but the real carrier is shown only after he logs in. If he is from abroad his fees double and he bolts outta my shop...

Share this post


Link to post
Share on other sites