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.comCompatibility: Tested with ZenCart v. 1.3.5
Purpose:
This contrib does a few things related to currency management:
- 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).
- 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.
- 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.phpInstallation:
- 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:
- 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.
- 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:
- ALWAYS back up all files before overwriting or running the sql scripts.
- 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.
- 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.
- 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).
- The ip2nation.sql file included in this contrib may be out of date. Download the latest from ip2nation.com and use that instead.
- Steven