
Originally Posted by
allmart
Hi lat9,
Thanks for the replies. The problem I am having is that the format of my Canadian postal codes have a space between then(L4H 5A1 for example). Where in your wonderful code can I put the code to replace/remove the spaces, specifics will be appreciated.
Thanks in Advance!!!
That shouldn't be an issue, so long as the minimum postcode length is set to 7, although some customers will enter that without the space.
Starting at line 63 of /includes/modules/shipping/zipship.php
Code:
// -----
// Gather the destination's zipcode, uppercasing and then truncating to the store's minimum zipcode length.
//
// NOTE: I'm counting on the address-book generation logic for the store to have properly ensured that the
// postcode entered is at least the minimum-length configured!
//
$this->dest_zone = false;
$this->default_zone = false;
$this->dest_zipcode = substr(strtoupper($order->delivery['postcode']), 0, (int)ENTRY_POSTCODE_MIN_LENGTH);
for ($i = 1; $i <= $this->num_zones; $i++) {
$current_table = "MODULE_SHIPPING_ZIPSHIP_CODES_$i";
if (defined($current_table)) {
$zipcode_table = constant($current_table);
if ($zipcode_table === '00000') {
$this->default_zone = $i;
} else {
$zipcode_zones = explode(',', strtoupper($zipcode_table));
if (in_array($this->dest_zipcode, $zipcode_zones)) {
$this->dest_zone = $i;
}
}
}
}
... make the highlighted changes:
Code:
// -----
// Gather the destination's zipcode, uppercasing and then truncating to the store's minimum zipcode length.
//
// NOTE: I'm counting on the address-book generation logic for the store to have properly ensured that the
// postcode entered is at least the minimum-length configured!
//
$this->dest_zone = false;
$this->default_zone = false;
$this->dest_zipcode = substr(strtoupper(str_replace(' ', '', $order->delivery['postcode'])), 0, (int)ENTRY_POSTCODE_MIN_LENGTH);
for ($i = 1; $i <= $this->num_zones; $i++) {
$current_table = "MODULE_SHIPPING_ZIPSHIP_CODES_$i";
if (defined($current_table)) {
$zipcode_table = constant($current_table);
if ($zipcode_table === '00000') {
$this->default_zone = $i;
} else {
$zipcode_zones = explode(',', strtoupper(str_replace(' ', '', $zipcode_table)));
if (in_array($this->dest_zipcode, $zipcode_zones)) {
$this->dest_zone = $i;
}
}
}
}
Bookmarks