redesign country /zones implimentation

Posts: 99
Joined: 08/08/2007
Bug FinderGetting busy with the Ubercode.Not Kulvik

After taking a look at how countries are handled in ubercart, and a short discussion yesterday in #drupal-ubercart, it looks like the countries interface should be redesigned.

My suggestion is that we make countries depend on the location module, and use their *much more* complete country information.

I've posted my initial findings and ideas here: http://groups.drupal.org/node/13951

What will this accomplish?
1) take the pressure off ubercart to create and maintain country and zone information
2) allow the location api to further refine postal codes, address formats, etc
3) less database tables
4) one less thing to debug =D

I'm also suggesting to the location people that the API allows the apps implementing the location module be the ones that select which countries are to be used. There could be a selection that would allow ubercart to use the site-wide country list, or be able to choose their own country. Also thought about the ability of grouping countries into certain economic or regional sections, customizable by the user. This way its easier to select groups instead of trudging through 230+ countries.

Posts: 5379
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

+1 to the idea, Jakob. I've earmarked i18n improvements for the D6 cycle, and this is one of the biggies. I don't see a D6 version for location yet, though... any idea on progress there?

Also, my thought is that Ubercart should provide out of the box support for selling products within your own country. It just makes sense. So, you could specify your country in the admin area, and most places don't have to worry about "zones"... but perhaps that could be downgraded to a simple textfield? So hard to decide...

Then, if you want to sell to multiple countries, you get the location module and enable a UC integration module (or we have UC pick up on the location module and include the appropriate code automatically).

Thoughts?

Posts: 10
Joined: 08/13/2007

Hi,

Thanks for the super work you have done on Ubercart - I have been playing with it this week and am quite impressed. Even the effort you have put into countries is massively impressive - I know how tricky this can me!

Another approach might be to integrate with CiviCRM - though I suppose Civi is a bit heavy and you may not want to insist that all Ubercart sites have it installed. For us this would be helpful since every user in our site is also a contact in CiviCRM with full contact details already stored in Civi.

There is a Ubercart/Civi integration module, but it seems to only work one way - users that make an order are then added to Civi or their Civi contacts are updated. Perhaps this module could be extended to include grabbing contact details during the order process from Civi if it exists and allow people to update their details for billing purposes.

For us, the countries that are most needed are African countries - unfortunately so far you only support two African countries, so I'd have alot of work to do to create and contribute country files for the rest of them.

Cheers,

Tobias

Posts: 19
Joined: 03/22/2008
Bug Finder

Downgrading zone to a simple textfield would be the smartest and most straightforward solution. Everyone knows their own address, so they can type it in, and we could get rid of a lot of possible problems coming from outdated or erroneous location data.

Seriously, this is the only thing I dislike in Übercart.

Tom

--

Tom Szigeti

Posts: 99
Joined: 08/08/2007
Bug FinderGetting busy with the Ubercode.Not Kulvik

the biggest issue with this is the varied ways people type their countries and zones out.

For instance, with a textfield for washington state, you might get: WA, WASHINGTON, washington, W.A., WA., or wash
For a country, you might get US, USA, United States, us, usa, united states, united states of america, america, America.

Some of these cases can be resolved with case-checking and linking abbreviations to full names. However, what if someone misspells the zone/country? The biggest problem with this is taxes are derived from these fields. So are shipping information. I have a client who ONLY wishes to ship to USA. by making it a drop down, the customer knows exactly where items can be sold/shipped to. With ecommerce v3, we had about 300 orders per month come through, and at least 5 would fail spell check. Then we had to go retroactively charge them sales tax because it wasn't picked up by the system.

I think having drop downs is a very good idea. autocomplete is also promising, but still allows for mistakes. We should not be allowing people to type these in.

Posts: 99
Joined: 08/08/2007
Bug FinderGetting busy with the Ubercode.Not Kulvik

tobiaseigen wrote:
Hi,

Thanks for the super work you have done on Ubercart - I have been playing with it this week and am quite impressed. Even the effort you have put into countries is massively impressive - I know how tricky this can me!

Another approach might be to integrate with CiviCRM - though I suppose Civi is a bit heavy and you may not want to insist that all Ubercart sites have it installed. For us this would be helpful since every user in our site is also a contact in CiviCRM with full contact details already stored in Civi.


Yes, civiCRM is way to large to be a requirement for ubercart, IMHO. I'm working on a small module that'll interact with the geocoding website to get every country and zone id. We'll eventually need to re-write the uc_zones and uc_countries tables (we don't need them) but for now this script could just insert this information to the tables.

Posts: 99
Joined: 08/08/2007
Bug FinderGetting busy with the Ubercode.Not Kulvik

so I ran into a little issue with the current database. Specifically it has to do with subcountries, like the UK. There are 'states' within the countries of England, northern Ireland, Scotland, which need to be shown as zones. Then the countries should say something like: "United Kingdom - Scotland" since Scotland isn't its own country. (and doesn't have its own country code)

Because of this, we'll need to change how the uc_zones table functions in relation with the country code. I suggest changing zone_country_id from an integer relating to its iso number, into the ISO 3 (or two) letter country code. This will allow us to subrecurse into administrative regions.

For an exmaple, look at this:
http://ws.geonames.org/children?geonameId=6269131&style=FULL
The above are Boroughs for England. they all refernce ENG as the country code.

http://ws.geonames.org/children?geonameId=2635167&style=FULL
This is the ADM1 for subcountries of the uk. They all reference GBR. In my code I'm excluding subcountries that really are their own countries, like Isle of man and Jersey.

I'll have to look at a few more examples to get all the exceptions, but I'm getting close to being able to hit almost all cases.

Posts: 5379
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Awesome. Cool Thanks for the research, Jakob. fwiw, I totally agree that the custom integer zone_id was silly and shortsighted. It should be replaced w/ the ISO code sa you mentioned, and I suppose we can make the primary key be the numeric country code + the "zone's" ISO code.

Posts: 99
Joined: 08/08/2007
Bug FinderGetting busy with the Ubercode.Not Kulvik

heh okay so geocoding is taking yet another turn.

Everything was going great, I even got subzones to work perfectly. Then I ran into this.. Taiwan. Apparently the geonames api isn't totally complete. So this throws everything out.

Then I thought of a new idea! Perhaps you or lyle (whos the JS god?) can chime in here:
ZIP/POST code + Country! this is ALL you need to get the rest of the information you need. Cities, Zones (States/Provinces/Regions/AdminDists), etc.
Geonames has this information, but my associate got to thinking we could probably use the google maps API to get this information, then use JS to offer the users the region and/or city (depending on whats available).

I'm still hunting to see if google maps has address formats integrated or not, something for next week!