Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Auto set currency based on ip


alex121121

Recommended Posts

Would it be possible in Frozen BS 2.3.4 for the site to automatically adapt to currency based on ip without the customer having to select it? So the php program checks the ip of customer, then based on the result, it automatically sets the currency used in that country. I know some php people can write this but i was wondering it there is an addon for that.

Link to comment
Share on other sites

Hello @alex121121,

If you search the marketplace for your title you'll get several promising results.

The best in my opinion:

Auto change currency based on IP address

It may need some minor updates, but I believe it shouldn't be too difficult.

Link to comment
Share on other sites

@alex121121The addon mentioned by @raiwawas meant for the purpose you want. However, it uses a third-party site to check the IP and if you go to that site (mentioned on the addon page), you will see it says closed. The site may still work but IP's won' be updated, from the looks of it.

Also, if it does work, there is a limit in the code that only allows a certain number of checks for a certain period. That won't matter on slow sites but will on busier ones.

There was also a problem with that other site, as I recall, that if it was busy or not responding, the calling site would set and wait. Any benefit of showing the currency would be lost if a customer has to wait.

And one final point, IP's are not country-specific so the addon might report the wrong country. This is especially true in Europe where the countries are so close together.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

What is very easy to do is to link the currency to the language.

In admin: Configuration: My Store: Switch To Default Language Currency set to true

Then in each main language file, set the desired currency in aprox. line 39-40:

// if USE_DEFAULT_LANGUAGE_CURRENCY is true, use the following currency, instead of the applications default currency (used when changing language)
define('LANGUAGE_CURRENCY', 'USD');

 

Link to comment
Share on other sites

5 minutes ago, raiwa said:

What is very easy to do is to link the currency to the language.

That sounds great but do they have to select language themselves or can that be based automatically without asking them for permission and being illegal?

Link to comment
Share on other sites

Language is auto selected by browser language settings.

EDIT: Nothing illegal, each browser and WEB Site uses this. Just check your browser settings and visit multilanguage sites. Each site which supports your preferred browser language will show the site in that language.

Link to comment
Share on other sites

9 minutes ago, raiwa said:

EDIT: Nothing illegal, each browser and WEB Site uses this. Just check your browser settings and visit multilanguage sites. Each site which supports your preferred browser language will show the site in that language.

Yes yes, i know, i was talking about what Burt mentioned about obligation to ask for permission.

But do you know if the website will catch the difference between browsers in Great Britain USA and Canada, since it's the same language but different currency?

Link to comment
Share on other sites

Language ids include country specific part, see your browser preferences.

And in the english language file see at the very beginning:

// look in your $PATH_LOCALE/locale directory for available locales
// or type locale -a on the server.
// Array examples which should work on all servers:
// 'en_US.UTF-8', 'en_US.UTF8', 'enu_usa'
// 'en_GB.UTF-8', 'en_GB.UTF8', 'eng_gb'
// 'en_AU.UTF-8', 'en_AU.UTF8', 'ena_au'
@setlocale(LC_ALL, array('en_US.UTF-8', 'en_US.UTF8', 'enu_usa'));

 

 

Link to comment
Share on other sites

10 hours ago, alex121121 said:

Would it be possible in Frozen BS 2.3.4 for the site to automatically adapt to currency based on ip without the customer having to select it? So the php program checks the ip of customer, then based on the result, it automatically sets the currency used in that country. I know some php people can write this but i was wondering it there is an addon for that.

Alex, I modified and used this for years... 3 important points... Keep in mind - I'm not a coder... and have enough knowledge to be dangerous (I only reply because I have years of experience with this addon that should be taken into consideration that mostly has nothing to do with the code)

1) as @Jack_mcs pointed out the API is (I believe) is gone and wasn't very reliable when it was there which caused serious issues. I modified it to work with the Cloudflare which has a reliable IP country feature. If you happen to delivery your site on CF.... just replace the function with:

	$location = $_SERVER["HTTP_CF_IPCOUNTRY"];

2) there is some missing logic (fail safe) - if the function (or cloudflare) doesn't return the country.... that causes the price (ALL prices) on whichever country to be 0.00. Easy to fix up if you have only 2 currencies as I do... more difficult if you are thinking more than 2.

3) MOST IMPORTANT... there are some serious SEO considerations which I tried to work around for years. Although Google has crawlers all over the world, predominately, they crawl with USA based bots in North America (think Canada and Mexico) - and if you deliver your content dynamically to the USA you will be crawled as the bots see it... as USA. This includes currency. If you are not in the USA this will cause (did for me) your structured meta tag for all google listings to display in US currency no matter where your customers are located (example: we are in Canada and all our Google search results in Canada displayed in USD while using this addon).

Long story short, Google does NOT like dynamic pricing based on IP. I recently kill this addon and replaced it with a modal that delivers only to USA customers, asking if they would like to shop in USD. After this change my Google listings, within days, started to be re-crawled and displayed in my "home/default" currency. There were some other suprising results as well... example: bounce rate for USA customers dropped like a stone....

(with @burt permission I will share my modal... as it was his modal for another addon I used.... but you still need a API call that will work - again I used cloudflare)

Link to comment
Share on other sites

Very interesting stuff, Scott. But i think i will try to simply connect the currency to the language as Raiwa advised first. That should be a lot simpler and would avoid those SEO problems you mentioned. I appreciate your reply.

Link to comment
Share on other sites

Doesn't a PC user have to explicitly do something to set their browser language, otherwise it's likely to default to en_US? I seem to recall that issue popping up years ago when people were trying to get $language set reliably from the browser. Anyway, I wouldn't assume that the browser language has been correctly set for random shoppers.

Link to comment
Share on other sites

4 minutes ago, MrPhil said:

I wouldn't assume that the browser language has been correctly set for random shoppers.

I figured i'll assume it's been correctly set for most, and for those that's isn't, they apparently don't have problems with their browser set language anyway.

Link to comment
Share on other sites

For me in Spanish browsers its correct set by default installation. I believe its picking up the os settings?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...