I tried implementing this mod but nothing happens when you press the "confirm order" button and listed below is what is listed in the log:
Code:
PHP Warning: strpos(): Empty needle in /***/***/***includes/modules/shipping/zipship.php on line 113
Line 113 is listed in red below.
Code:
$this->dest_zone = false;
$this->default_zone = false;
// $this->dest_zipcode = substr(strtoupper($order->delivery['postcode']), 0, (int)ENTRY_POSTCODE_MIN_LENGTH);
$this->dest_zipcode = strtoupper(str_replace([' ', '-'], '', $order->delivery['postcode']));
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 {
// Read codes from config
$zipcodes = explode(',', str_replace([' ', '-'], '', strtoupper($zipcode_table)));
// Sort codes by length (longest first) and alpha
usort($zipcodes, function($a, $b){
$a = trim($a, '!');
$b = trim($b, '!');
return (strlen($a) < strlen($b)) ?: strcmp($b, $a);
});
// 1. For pattern matching, assume a "prefix". That is, for M***** just list M, and for L4**** just use L4.
// 2. In any listed postal code, if you add a "!" at the beginning or end of the code, it will exclude that one. eg: M4B1Y! or !M4B1Y would exclude all M4B1Y* codes.
// One caveat to note: if a postalcode pattern is present in more than one zone, the "last" non-excluded match will be used for calculating rates. (eg: if it matches in zones 1 and 3, then the rates from zone 3 will apply, ignoring its existence in zone 1).
// Check for exclusion patterns defined with a starting or ending ! symbol
foreach($zipcodes as $check_against) {
if (strpos($check_against, '!') === false) continue; // if no ! skip checking this iteration
if (strpos($this->dest_zipcode, trim($check_against, '!')) === 0) { // strip ! to do matching
$this->dest_zone = false;
// If exclusion detected, use "continue" to end this foreach and skip the next one as well
continue 2;
}
}
// Pass if the supplied code matches a defined prefix pattern
foreach($zipcodes as $check_against) {
if (strpos($check_against, '!') !== false) continue;
if (strpos($this->dest_zipcode, $check_against) === 0) {
$this->dest_zone = $i;
// If a match is found, end this foreach
break;
}
}
}
}
}
Thanks in advance for your help!
Bookmarks