State selector – the easy way
multimixer | work | Wednesday December 2 2015We all know the very annoying behaviour of osCommerce regarding country – state selection on the create account page:
You type in a state, select a country, submit the form, and return to the same page with an error message that the state entry was not correct. You can now select a state and proceed.
Practically this mean that each customer who create an account on the store is presented that error message and has to submit the form twice, each customer has to go through the frustrating experience that she/he did something wrong, right at the beginning of the checkout process. Not very motivating I think
This happens on every page where customers can enter an address
- create_account.php
- checkout_payment_address.php
- checkout_shipping_address.php
- address_book_process.php
It only work correctly in case the selected country has no zones. The majority of the stores do use zones of course
The reason for this behaviour is build into the system from day 1, the way the system work is as follows, in simple terms:
if there is a country selected, check if there are zones for that country.If the country has zones, display the drop down of zones/states, if no zones, display a text input field.If no country is selected, display a text input field
Now, the system know if there is a country selected only after the form is submitted. It “decide” to display a drop down of states or not only after the form is submitted
You are lucky to get an account created in 1 step and without an error message only if the country you selected has no zones or if you typed in the zone name exactly as set in admin, not very likely to happen.
There are of course some solutions available as add ons, they all modify quite many files and/or don’t work well.
I created a completely self contained system, with no code changes at all, that produce following behaviour
1) if no country is selected, a text appear at the state field: “select country first”2) If a country get selected, the text disappear and automatically is replaced by:2.1) A states dropdown, in case the country has zones, people have to choose from there2.2) A text input field in case the country has no zones, people can enter any text
If you change the country selection, the sate field update automatically, showing either a updated drop down or a text input field
The critical and important part is, that the state selection drop down appear before the form is submitted letting customers do the correct selection on the drop down
In admin, all you have to do is, install the state selector module and select what pages you want to use it on.
The page selection was added in case you are using other, alternative checkout method, like for example “Purchase without account – the easy way“
The State Selector extension does not require any file changes. Installation consist of uploading 3 files to the server (+ one more or each additional language you use) and installing the module in admin
Get in touch if you want to have this on your store