If this is your first visit, check our documentation. To post, register or login.
Forums / All Other Contributions/Addons / userCurrency - updated for 1.3.5

userCurrency - updated for 1.3.5

Started by s_mack on 11 Sep 2006, 6:59 AM · Views: 27,024

Results 1 to 20 of 148
11 Sep 2006, 6:59 AM
#1
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

userCurrency - updated for 1.3.5

Available in the Downloads section (or soon will be when they finish reviewing).

From the readme:> Contribution: Customer Currency

Release: 2.00
Author: s_mack
Credits: IP to Country mapping data provided for free by ip2nation.com

Compatibility: Tested with ZenCart v. 1.3.5

Purpose:

This contrib does a few things related to currency management:

  1. When a guest (non logged in user) visits, their IP is checked against a database to determine country. This is cross-referenced with a table of currencies for each country. Provided that currency is defined in your Localization->Currencies section of your Admin page, the currency will be pre-selected for the customer. Otherwise your default currency will be used. The customer may choose a different currency (provided you give them that ability) and it will be remembered as expected for the rest of the session. This feature is optional (see installation and notes).
  2. When a user first creates an account, the address s/he chooses is used to determine the customer's preferred currency. If the country they choose does not have a matching currency, or if that currency is not defined in your Localization->Currencies section, the default currency will be stored.
  3. Whenever a user selects a currency, that value is stored in the customers table so that it will be remembered from session to session (whenever logged in, otherwise treated as guest). Without this contrib, a customer will always revert back to the default currency which can be very confusing if currencies are similar (Canadian $ vs. American $ for example).

File List:

./changelog.txt
./ip2nation.sql
./ReadMe.txt
./uninstall.sql
./userCurrency.sql
./includes/auto_loaders/config.userCurrency.php
./includes/extra_datafiles/userCurrency_database_names.php
./includes/init_includes/init_userCurrency.php

Installation:

  • Copy all files in the /includes folder to your shop, retaining folder structure. No core files are touched.
  • Apply the included sql files as described below. See the ZenCart forum for help with applying sql patches/files/queries.

There are three sql files. The first (customers_currency.sql) is required and alters both your CURRENCIES table and your CUSTOMERS table. The second (ip2nation.sql) provides the functionality described in point #1 of the Purpose section above and is optional. Without it, a guest will always start with your default currency. Why not install it? There are a two reasons:

  1. The database containing the mapping data from ip to country is quite large. It could easily double your database size depending on your store. It may not be worth the benefit it provides.
  2. The data needs to be updated periodically. It is updated monthly by a service called ip2nation.com. Use the download link there from time to time to get new data. Again, the benefit may not be worth the effort.
    The third sql file (uninstall.sql) is used for removing this contribution from your database (see below).

Un-Installation:

  • Apply the uninstall sql file to reverse the database entries.
  • Delete all the files from this package (see list above) from your store.

Notes:

  1. ALWAYS back up all files before overwriting or running the sql scripts.
  2. The ip2nation sql scripts are huge! and can take several minutes to process - give it time and if an error occurs, revert to your backup and try again.
  3. The world is an ever-changing place and I don't suppose to keep up. Sometimes there are huge events like the Euro coming into existence, sometimes countries change (Zambia/Congo for example), and sometimes they just mess around with currency and or country codes. Over time, I have no idea how useless this contrib may become because of this. However, you really only need to concern yourself with countries that use the currencies you've defined... so if you don't use the Haitian Gourde then you don't need to worry if Haiti adopts the Iceland Krona as its official currency.
  4. ALWAYS define your countries (if you add or alter any) and currencies using their OFFICIAL ISO codes. Country codes are governed by ISO 3166 and currencies are governed by ISO 4217. I caution you to watch your sources and double-check because I found a lot of conflicting data on websites (I went with a 'majority rules' methodology for choosing which are correct).
  5. The ip2nation.sql file included in this contrib may be out of date. Download the latest from ip2nation.com and use that instead.
  • Steven
11 Sep 2006, 7:09 AM
#2
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

link

  • Steven
13 Sep 2006, 2:55 AM
#3
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

While working on another contrib, I came up with a different way of handling database calls so I've updated this contrib to version 2.10 and will be available in the download section shortly.

There are no new features, so not any significant reason to upgrade unless you are keen on keeping your core files and database as untouched as possible.

  • Steven
20 Sep 2006, 9:58 AM
#4
dhermanus avatar

dhermanus

New Zenner

Join Date:
Sep 2006
Location:
Sydney, Australia
Posts:
44
Plugin Contributions:
0

Re: userCurrency - updated for 1.3.5


Hi Steven,

Does this mod automatically change all product price currencies to the customer's selected currencies. (Through conversion via the currencies table value column).

Thanks,
Deddy

20 Sep 2006, 1:54 PM
#5
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

This mod doesn't, no... that's done anyway through zencart. :) Obviously you don't want someone to see a US$100 item and simply change that to 100 pesos! ZenCart's a little smarter that.

This mod doesn't touch the code for exchange calculations... nor does it need to. You control your currencies in Admin --> Localization --> Currencies.

  • Steven
20 Sep 2006, 2:21 PM
#6
dhermanus avatar

dhermanus

New Zenner

Join Date:
Sep 2006
Location:
Sydney, Australia
Posts:
44
Plugin Contributions:
0

Re: userCurrency - updated for 1.3.5

Thanks Steven,

I am studying the codes :lamo: to see if I can write extra functionality into Zencart 1.35, so that it can list multiple currencies for each product listing -> one currency payment. If you or anyone can point me to the right direction for doing that ... that'll be great.

Cheers,
Deddy

20 Sep 2006, 2:37 PM
#7
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

I'm not sure why you'd want to do that.

I mean, I guess I understand having multiple values showing simultaneously but why funnel that into one payment currency?

From a marketing perspective, as well as a user friendly perspective, I really don't think you want to show a currency that you won't accept payment in. If you let them choose Euros, you had better accept Euros. Beyond avoiding confusion and frustration... there is a very serious reason why... Accuracy. You have NO IDEA what exchange rate their credit card or bank is going to give them. Say they are in Canada and you accept payments in US dollars. They come to your site and see US$100, C$115. Ok, so they think they are being charged C$115. You only accept payment in USD, and that's cool... they still think it will convert to C$115 as you stated. But their credit card doesn't use "posted" rates... no... their credit card (like all credit cards) ups that value up at LEAST 4% PLUS charges them a 2.5% conversion penalty... so now they see a bill of something like C$120 on their bill and they are mad at you.

If you only accept USD, then stick with USD.

Now, ignoring that (lets say you do accept multiple currencies) I would argue that this mod is better than displaying multiple currency values at the same time. Why show someone from Canada both US and Canadian dollars when you can show them what they want - Canadian dollars? This mod will automatically detect where they are from (within limitations) and pre-select that currency for them.

Give customers what they want.

  • Steven

ps. But to answer your question... study the /includes/classes/currencies.php file.

20 Sep 2006, 4:42 PM
#8
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: userCurrency - updated for 1.3.5

I love the idea of offering multiple currency options and your module is even cooler as it can pre-select. However, the reason that I've stopped offering anything except the Euro is mainly for book keeping reasons. I found it cumbersome to receive multiple currency orders. Is it possible to accept multiple currencies but have them ALL default to the default currency at checkout?

Thanks - Tim

20 Sep 2006, 4:51 PM
#9
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

Possible, sure... but like I was saying above... you don't want to do this.

If you have a customer from the UK, for example... the BEST thing for him is to be able to select and pay in GBP. The next best thing is for him to just deal with Euros.... the WORST thing for him is to select GBP and then have to pay in euro. Its just confusing and he ends up feeling duped.

If you want them to shop in GBP, then offer GBP as a currency that you accept. If you don't want to accept GBP then don't let them shop in GBP.

Incidentally, PayPal is excellent at dealing with multi-currencies. So perhaps one idea is to have multiple currencies available to people that choose PayPal, but convert to your default currency if they choose another method of payment? I haven't really thought about the consequences of that thought.

  • Steven
2 Nov 2006, 9:59 PM
#10
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

Just a note: This contrib works fine with 1.3.6

  • Steven
5 Jan 2007, 12:45 PM
#11
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: userCurrency - updated for 1.3.5

Hi Steven - Thanks for this great module.

At this time the Euro is the only currency we accept. However, I am certain that it would benefit us to accept certain other currencies, as well. In advance of installing this module I wanted to peruse the forum for any helpful hints, advice, glitches etc. In doing so I ran across a related thread in which you suggested visiting http://www.smartieparts.com/shop/ as an example of this module in use.
I see that the Canadian Dollar is the default and in fact was the currency offered when I visited despite the fact I am in Italy. Is there a reason why the Euro wasn't automatically offered?

I'm just wondering if, after some time has passed, you've found that it just wasn't worth having that option installed for some reason.

Also, from test orders on my own site I see that when a customer orders in another currency there seems to be no mention of the default currency anywhere in the transaction. By this I mean, for example, the invoice is only in the currency selected, with no mention of exchange rates, etc. Is this what you do when dealing with customer orders in real life situations? What about the credit card slip? When I run a credit card in my POS here in Italy, the currency is obviously the euro. How do you deal with that?

Sorry to be both a pain and a nimrod where this is concerned. It's just that for some reason my brain tends to fail while trying to grasp currencies, exchange rates etc.

Thanks for your help, I really appreciate it.

Tim

6 Jan 2007, 5:53 PM
#12
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

Hi Tim,
My site certainly does still use the code and I do find it useful. Why did it show Canadian dollars when you visited? Well, either I have a bug I need to work out (I change my site drastically on Jan 1) or your IP falls into an unknown range. The IP to Country data comes from IP2Nation.com (updated monthly... usually) and they are American so I figure they probably concentrate mostly on North American data, I'm not sure. But they simply can't have every IP in the world and know where it comes from, so if the user's IP isn't in a defined range then it just can't know. If you go to https://www.whatsmyip.org and let me know what your ip is, it will help me figure out if this is a bug or if you just aren't in the range.

Your 2nd Q: That's correct... you show the currency and that's it - no exchange rates or anything. But in your case, it sounds like you CAN ONLY accept the euro! So don't try to accept others. If you can't take an American dollar payment in American dollars from an American customer, then don't accept American dollars on your site...

I know some people have asked how to show American dollars but really accept Euros... what's the point? Just to confuse the customer? If they see US$100 they expect to pay in USD, not some converted value of Euros. So on my site, for example, I bank in Canadian dollars but I can accept (thanks to PayPal) a plethora of currencies. Because of my market (smart car owners) I only bother with USD, CAD, EUR, and GBP. I could also accept AUD and YEN (since Japan and Australia have smart cars too) but I get so few requests from these countries that it is simply not worth it. When a customer from Italy orders parts from me and chooses Euros... they pay in euros and I receive euros. This is important especially for refunds, because I can refund in Euros. If instead I forced you to pay in CAD, then first off you would get charged a fee for converting from Eur->Cad but when I refund you would be charged another fee for converting from Cad->Eur!! Can you imagine? You order 1000 euro worth of goods from me and pay instantly. Then I find out I can't fulfill the order or you change your mind or whatever... so I refund it, and in the end you only get something like 950 euro?!?! You'd be a little mad I think, having paid good money for absolutely nothing.

If you aren't able or willing to hold balances in foreign currencies (paypal is the easiest way to do this) then stick to Euros only. That way, at least, customers know up front they are dealing in foreign exchange and know what to expect.

I hope that helps.

  • Steven
7 Jan 2007, 7:22 AM
#13
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: userCurrency - updated for 1.3.5

s_mack:

If you go to https://www.whatsmyip.org and let me know what your ip is, it will help me figure out if this is a bug or if you just aren't in the range.

I hope that helps.

  • Steven

Hi Steven - Thanks for the insight. I believe that I'll take your advice and stick to the Euro.

My IP is 87.3.123.165. Hopefully that will help you determine if you have a bug or not.

Thanks again - Tim

7 Jan 2007, 8:08 AM
#14
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

Its a bug... not sure when or how it was introduced, but thanks for helping me figure it out. Your IP certainly resolves to "Italy" so somehow my code got broken when I upgraded my site. Probably something simple.

  • Steven
7 Jan 2007, 8:12 AM
#15
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: userCurrency - updated for 1.3.5

Another related question, if I may: One of the reasons that we don't offer PayPal is concern about returns. Right now, when a customer orders online, we actually run the credit card just prior to shipping. That way if an item is out of stock we can just notify the customer via email and offer other options, without the headache of having to refund. Obviously this is not the case with Paypal. Once ordered, it's ordered, right?

How difficult is it if you have a return with Paypal?

7 Jan 2007, 8:14 AM
#16
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: userCurrency - updated for 1.3.5

Another related question, if I may: One of the reasons that we don't offer PayPal is concern about returns. Right now, when a customer orders online, we actually run the credit card just prior to shipping. That way if an item is out of stock we can just notify the customer via email and offer other options, without the headache of having to refund. Obviously this is not the case with Paypal. Once ordered, it's ordered, right?

How difficult is it if you have a return with Paypal?

7 Jan 2007, 8:22 AM
#17
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

I take it back... no bug.

I just hardcoded your IP into my code, and went to my site as a "guest", and it chose Euros as expected.

So why it didn't choose it for you, I'm not sure. Either, the system was unable to get your IP... or possibly got your wrong IP (for example, it got your 'local' address instead of your router's address?) or perhaps... well, I'm not sure.

  • Steven
7 Jan 2007, 8:24 AM
#18
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

MeltDown:

Another related question, if I may: One of the reasons that we don't offer PayPal is concern about returns. Right now, when a customer orders online, we actually run the credit card just prior to shipping. That way if an item is out of stock we can just notify the customer via email and offer other options, without the headache of having to refund. Obviously this is not the case with Paypal. Once ordered, it's ordered, right?

How difficult is it if you have a return with Paypal?

I know the PayPal experience varies from country to country, so I can't say for sure in your case... but in Canada/US at least, returns are simple. You just log in, find the transaction, and refund all or part of the purchase.

  • Steven
7 Jan 2007, 8:30 AM
#19
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: userCurrency - updated for 1.3.5

s_mack:

I take it back... no bug.

I just hardcoded your IP into my code, and went to my site as a "guest", and it chose Euros as expected.

So why it didn't choose it for you, I'm not sure. Either, the system was unable to get your IP... or possibly got your wrong IP (for example, it got your 'local' address instead of your router's address?) or perhaps... well, I'm not sure.

  • Steven

I just visited your site in both FireFox and the newest IE, both times the Canadian dollar was offered.

7 Jan 2007, 4:30 PM
#20
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: userCurrency - updated for 1.3.5

Yes, I wouldn't think the browser would matter... its more likely that the zen sniffer that detects your IP can't get it (firewall or router blocking it), or is getting the wrong one (if you are behind a router, then you have two IPs, an internal one and a public one - sometimes the internal one gets detected). I don't know what whatsmyip.org uses, but it always seems to get the right one no matter what.

I tested again and again... hardcoding various ips from europe, the us, canada, and the uk into the code and everytime it correctly chooses the appropriate currency, so the only option left is the "detection" is the problem here - and that's not my code. Its the zen function "zen_get_ip_address()"

In any case... the auto-selection of currency is really the very minor part of this contribution. The MUCH more significant feature is that a customer's currency preference is kept in the db for future visits so they don't always have to re-choose the one they want. The auto-selection thing is only for guests as a neat little convenience feature. If it doesn't work 100% of the time, I'm certainly not concerned about it.

  • Steven