The modification is based on the Austshipping2 and UK Postcode Validation contributions.
We use TNT Express as our only delivery method. TNT split the UK into three Zones. Fundamentally they are UK mainland, Channel Islands & Offshore and Northern Ireland. The problem we have using counties as a lookup for the zone is that many people do not enter a county or input the wrong county, same goes for postal towns. We don’t want a drop down list either as we plan to integrate an address lookup API in the future. The only ‘bullet proof’ method is to organise the zones based on the first portion of the postcode, and this is where I am having a problem.
I noticed that the ‘[url removed, login to view]’ splits the postcode into two portions as part of the validation process. I have added a field ‘entry_postcode_short‘ to the table ‘address_book’. My idea was to get the script to write the first portion of the validated postcode to the field ‘entry_postcode_short‘, and to use this field as the lookup for the zone. I have ‘hard coded’ this into the [url removed, login to view] script as a test and it works like a dream.
I have bought a postcode list from Royal Mail and have written two SQL statements which I have attached. One is a list of the first portion of the postcode with related zones. The other is a list of the three zones with their surcharges and kilo rates.