Re: Shipping in NZ - help to figure this out
Hi again,
Have managed to get a code that appears to work during the account creation stage - it will check the users input against the fastway_zones to see if the postcode entered is in the database.
add the following code to create_account.php (includes/modules/your_template)
// existing code
if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
$error = true; $messageStack->add('create_account',ENTRY_POST_CODE_ERROR);
// add this code to check postcode
} else {
// check Zen Cart for duplicate postcode
$sql = "select * from " . TABLE_FASTWAY_ZONES . "
where f_postcode = :postcode:";
$check_postcode_query = $db->bindVars($sql, ':postcode:', $postcode, 'string');
$check_postcode = $db->Execute($check_postcode_query);
if ($check_postcode->RecordCount() < 1 ) {
$error = true;
$messageStack->add('create_account', ENTRY_POST_CODE_ERROR2);
}
You will also need to define the TABLE_FASTWAY_ZONES and ENTRY_POST_CODE_ERROR2 for this to work.
I haven't tested this on a live shop yet, but it appears to work on my localhost.
The only issue now is trying to keep the database up to date with any changes NZ Post make to the postcodes.
Regards,
Mike.
As the Shipping in NZ thread has been closed...
and there's a few of us on here who come in intermittently, not to mention lots of updates... I was wondering if this thread could be reopened and kept open?
I'm looking at the issue the guys last mentioned in about integrating Fastway Couriers properly to NZ Post Codes... is changing an sql database purely about time and motivation (the download they refer to is an Australian version and has 3000 records).
In NZ, our postal code is based on streets, not towns, so I am assuming for it to work accurately, I will have to modify the data along the lines of:
Currently = suburb, state, postcode, region, delivery, zone
so do I just add in an extra column? and find some script somewhere in the files attached to it and modify them to pick up the extra column?
This will be my first foray into delving into the deep dark workings of sql.... and all because I've uploaded the latest version on my laptop to finally upgrade my site from 1.2.7... I decided it was easier to start from scratch and do it properly this time... lol