Having all sorts of problems with the state/province field with UK addresses.

Firstly, the list of UK provinces in ec_store.localization.inx is actually wrong. A lot in the list are actually towns/cities.

Secondly, the UK use the full name of provinces in addresses, but the ecommerce module changes this to a three letter code which it then sends as part of the address to the payment gateway. Which makes the address submitted appear incorrect (and would be, if you printed it that way when shipping), through no fault of the user. I tried altering the provinces in the ec_store.localization.inc with their fullname i.e.

'Avon' => t('Avon')

...But there's validation that stops this. I'm not much of a coder and didn't know how to exclude UK addresses from this validation.

Thirdly, the province field is required and submitting the form with it empty brings up the error "Invalid state. Try to use the state code.". I searched and turned up some old threads with similar problems, but it looks like the problem should be solved?

Fourthly, having left the province field empty and updated the form, it brings up with Invalid state error. Then, I now find two state/province fields, one free text box, and one empty list. So there's no ability to even complete the transaction any more. (see attached screenshot1.png)

Fifthly, for some reason states/provinces are each listed three times, this is the weirdest problem. As if the array is being called three times, but I can't see why it would be. This happens whichever country is selected, so long as there's a list to select from. (see attached screenshot2.png)

Sixthly, Whatever changes are made in ecsettings/ctype/ec_address i.e. which countries are selectable, whether second line of address is needed, or zip code - they are ineffective, all countries are selectable and the second line of address/zip are available even if these are deselected.

Because I've had so many problems with addresses, I've tried to turn the functionality off completely. I'm using paypal so thought I could just get shipping addresses through that. But I can't find anywhere to turn it off - turning off the address module has no effect apart from to remove storing of addresses on the site.

I'm losing the will, please help!

CommentFileSizeAuthor
screenshot2.png40.81 KBincredisulk
screenshot1.png31.39 KBincredisulk

Comments

gordon’s picture

Thanks for the information.

This is sometimes hard for me, not being in the UK, so I am not 100% sure how things are addressed there.

I will work though this list and see what I can do.

Gordon.

incredisulk’s picture

I could provide a list of UK counties (provinces) if that's any use?

gordon’s picture

Yes that will be good, as I will be able to add them into the system by default.

Anonymous’s picture

Shouldn't this module be using ISO-3166-1 and ISO-3166-2 for countries and country subdivisions, respectively? This is how I've always solved this problem.

http://en.wikipedia.org/wiki/ISO_3166-1
http://en.wikipedia.org/wiki/ISO_3166-2

In fact, ISO-3166-2 even specifies the name of subdivisions: state, district, province, etc and that can be used.

davea’s picture

This appears to be caused by 2 problems that are interelated.

When form validation fails, the form is not updated by the javascript to collapse the state textfield and state select field together.

Also, the name doubling of the states occurs because of a naming collision in Drupal.settings.eCommerce.countries. This collision occurs due to the javascript being added more than once to the same form.

I added the javascript call, ec_store_address_add_js(), to the validation functions and removed the same from ec_store_address_form.

Please test this out by downloading the latest dev version.

Thanks,
Dave

incredisulk’s picture

@davea

Thanks for that, tested and the new dev release seems to fix the 4th (inoperative form following empty state/province submission) and 5th (triplicated state/province) issues on my list. Cheers!

@Baegle

Looking at the links you posted, I think this is actually exactly the problem for the other issues...

The ISO-3166-1 and ISO-3166-2 lists lead to an unintuitive and incorrect list for the UK and potentially other countries. The problem with ISO 3166-2:GB is that it lists firstly 'two tier counties', then 'London Boroughs', 'metropolitan districts', 'unitary authorities' etc etc etc... So we get a list that's not alphabetical, includes certain cities/towns which will already have been entered previously in the form, and full of various other problems in terms of non-alphabetical and unintuitive groupings, replication and exemption. A mess, basically.

I'm not knowledgeable enough on this subject but I think it must be impossible to completely rationalise worldwide address systems in this way and that the UK cannot be the only problem.

For example, the average UK resident would list their address as House number/Street -> Village (optional) -> Town -> County (optional) -> Post Code, Country (mostly optional). The same resident would be unlikely to know what groupings like 'two tier counties' mean. Also, while the 3 letter codes attributed to ISO 3166-2:GB 'areas' might mean something to statistical engines they mean nothing to UK residents or the postal service, so submitting them instead of the full string is erroneous. It should be the full text.

For example, I live in Doncaster which could be broadly described in international terms as a Province, since it's a 'metropolitan district', but Doncaster is also a Town, and is in the county of South Yorkshire. So while 'Doncaster' is an option in State/Province in the localization.inc, it would already have been entered in the Town/City field, and nobody in Doncaster would look for it in a select list for State/Province, and furthermore no resident would consider it a State, or a Province, or a County. If they did find it and submit it in order to complete their purchase, Doncaster as a state/province would be sent to the payment gateway as DNC, which as I say means nothing to a resident or the postal service, and may lead to confusion with the postal code it would prefix.

I think the solution here in the short term could be for UK addresses to have an optional, free text, State/Province field (the label of the State/Province field could also do with being contextual, so that for the UK it is labelled 'County')?

This would still pose problems, but fewer. There aren't any tax differences. Only problem would be postal charges, which I'm not sure could be easily corrected by the current system anyway, for most online shops. Unless we're talking about heavy goods and specialist couriers, I think the postal costs within most of the UK would be the same, apart from in certain cases with Islands off the mainland. I can't see it making any difference to international shipping to the UK.

I've noticed that most big online shops in the UK auto-fill the address from a database based on house number and postcode, I suppose this is what solves UK addresses frustrating allocation of regions for calculation of things like tax/postage, and correcting for user error.

incredisulk’s picture

Below is a list of UK counties. However, like I say, state/province/county for the UK should be optional - there's argument over counties that have been abolished, but people might still consider themselves part of it (i.e. Avon), and just how these counties should be listed (i.e. whether County Durham should be under 'County Durham' or just 'Durham').

Argyll and Bute
Bath & NE Som
Bedfordshire
Berkshire
Blaenau Gwent
Borders
Bristol
Buckinghamshire
Cambridgeshire
Carmarthenshire
Ceredigion
Cheshire
Conwy
Cornwall
County Antrim
County Armagh
County Down
County Durham
County Londonderry
County Tyrone
Cumbria
Denbighshire
Derbyshire
Devon
Dorset
Dumbarton and Clydebank
Dumfries & Galloway
Dyfed
East Ayrshire
East Dunbartonshire
East Renfrewshire
East Riding of Yorkshire
East Sussex
Essex
Fermanagh
Fife
Flintshire
Glamorgan
Glasgow
Gloucestershire
Grampian
Greater Manchester
Gwent
Gwynedd
Hampshire
Herefordshire
Hertfordshire
Inverclyde
Isle of Wight
Kent
Lancashire
Leicestershire
Lincolnshire
London
Manchester
Merseyside
Norfolk
North Ayrshire
North Lanarkshire
North West Highlands
North Yorkshire
Northamptonshire
Northumberland
Nottinghamshire
Oxfordshire
Pembrokeshire
Powys
Renfrewshire
Rhondda Cynon Taff
Shropshire
Somerset
South Ayrshire
South Gloucestershire
South Lanarkshire
South Yorkshire
Staffordshire
Suffolk
Surrey
Tayside
Torfaen
Tyne & Wear
Warwickshire
West Lothian
West Midlands
West Sussex
West Yorkshire
Wiltshire
Worcestershire

gordon’s picture

Status: Active » Fixed

I have done a lot of work on this and it should all be fixed now. Please let me know if there are still any issues.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

carlhinton’s picture

The state error still occurs even when using the development version of the code.

The code is faulting in ec_checkout/js/checkout.js Drupal.settings.eCommerce.regions[country]['state_name'] is getting an array instead of text and the .toLowerCase() creates an error. Line 25

My colleague partially fixed this with:

      if (Object.prototype.toString.call( Drupal.settings.eCommerce.regions[country]['state_name'] ) === '[object Array]') {
        	  options = '<option value="">' + Drupal.t('Select a ' + Drupal.settings.eCommerce.regions[country]['state_name'][0].toLowerCase()) + '</option>';
          } else {
        	  options = '<option value="">' + Drupal.t('Select a ' + Drupal.settings.eCommerce.regions[country]['state_name'].toLowerCase()) + '</option>';
          }

However, this does not completely fix the fault and still gives two labels.

What is needed is to find the root cause, which must be finding where the [country]['state_name'] is being double loaded.

carlhinton’s picture

Status: Closed (fixed) » Needs review
gordon’s picture

Thanks for the feedback. I don't know a lot about the UK address system so rely on other people to tell me where I have gone wrong.

screenshot2 is an old problem, that know has been resolved. Please make sure that you are running the latest version of ec. 6.x-4.6

The last maybe incorrect, if you can give me a link to a canonical source where I can get the right list of all the provinces and I can get this updated.

Gordon.