Jump to content
Sign in to follow this  
taylorjes

Local Delivery Service - Canadian Postal Code Fix

Recommended Posts

So, I've been tinkering with Local Delivery Service v3.0 in an attempt to reduce the work needed to canvas an area for delivery.

 

I've pinpointed the area of the code I need to fix, but I'm no PHP guru and frankly I'm stumped.

 

I would like to do three things

 

First:

$order->delivery['postcode'] = strtoupper($order->delivery['postcode']);
$order->delivery['postcode'] = str_replace(' ', '', $order->delivery['postcode']);

I added below:

$order_foo = substr(str_replace(' ', '',strtoupper($order->delivery['postcode'])), 0, 3);//strip PC to prefix #A#

 

Second:

   if (in_array($order->delivery['postcode'], $zipcodes0)){$check_flag = true;}
   elseif (in_array($order->delivery['postcode'], $zipcodes1)){$check_flag = true;}
   elseif (in_array($order->delivery['postcode'], $zipcodes2)){$check_flag = true;}
   elseif (in_array($order->delivery['postcode'], $zipcodes3)){$check_flag = true;}
   elseif (in_array($order->delivery['postcode'], $zipcodes4)){$check_flag = true;}
   elseif (in_array($order->delivery['postcode'], $zipcodes5)){$check_flag = true;}
   elseif (in_array($order->delivery['postcode'], $zipcodes6)){$check_flag = true;}
   elseif (in_array($order->delivery['postcode'], $zipcodes7)){$check_flag = true;}
   elseif (in_array($order->delivery['postcode'], $zipcodes8)){$check_flag = true;}
   elseif (in_array($order->delivery['postcode'], $zipcodes9)){$check_flag = true;}
   elseif (in_array($order->delivery['postcode'], $zipcodes10)){$check_flag = true;}

I want to change to:


   if ($order_foo == $zipcodes0){$check_flag = true;}
   elseif ($order_foo == $zipcodes1){$check_flag = true;}
   elseif ($order_foo == $zipcodes2){$check_flag = true;}
   elseif ($order_foo == $zipcodes3){$check_flag = true;}
   elseif ($order_foo == $zipcodes4){$check_flag = true;}
   elseif ($order_foo == $zipcodes5){$check_flag = true;}
   elseif ($order_foo == $zipcodes6){$check_flag = true;}
   elseif ($order_foo == $zipcodes7){$check_flag = true;}
   elseif ($order_foo == $zipcodes8){$check_flag = true;}
   elseif ($order_foo == $zipcodes9){$check_flag = true;}
   elseif ($order_foo == $zipcodes10){$check_flag = true;}

 

Third:

	if (in_array($order->delivery['postcode'], $zipcodes0)){$shiping_costs = MODULE_SHIPPING_DLY3_COST0;}
	elseif (in_array($order->delivery['postcode'], $zipcodes1)){$shiping_costs = MODULE_SHIPPING_DLY3_COST1;}
	elseif (in_array($order->delivery['postcode'], $zipcodes2)){$shiping_costs = MODULE_SHIPPING_DLY3_COST2;}
	elseif (in_array($order->delivery['postcode'], $zipcodes3)){$shiping_costs = MODULE_SHIPPING_DLY3_COST3;}
	elseif (in_array($order->delivery['postcode'], $zipcodes4)){$shiping_costs = MODULE_SHIPPING_DLY3_COST4;}
	elseif (in_array($order->delivery['postcode'], $zipcodes5)){$shiping_costs = MODULE_SHIPPING_DLY3_COST5;}
	elseif (in_array($order->delivery['postcode'], $zipcodes6)){$shiping_costs = MODULE_SHIPPING_DLY3_COST6;}
	elseif (in_array($order->delivery['postcode'], $zipcodes7)){$shiping_costs = MODULE_SHIPPING_DLY3_COST7;}
	elseif (in_array($order->delivery['postcode'], $zipcodes8)){$shiping_costs = MODULE_SHIPPING_DLY3_COST8;}
	elseif (in_array($order->delivery['postcode'], $zipcodes9)){$shiping_costs = MODULE_SHIPPING_DLY3_COST9;}
	elseif (in_array($order->delivery['postcode'], $zipcodes10)){$shiping_costs = MODULE_SHIPPING_DLY3_COST10;}

to:

	if ($order_foo == $zipcodes0){$shiping_costs = MODULE_SHIPPING_DLY3_COST0;}
	elseif ($order_foo == $zipcodes1){$shiping_costs = MODULE_SHIPPING_DLY3_COST1;}
	elseif ($order_foo == $zipcodes2){$shiping_costs = MODULE_SHIPPING_DLY3_COST2;}
	elseif ($order_foo == $zipcodes3){$shiping_costs = MODULE_SHIPPING_DLY3_COST3;}
	elseif ($order_foo == $zipcodes4){$shiping_costs = MODULE_SHIPPING_DLY3_COST4;}
	elseif ($order_foo == $zipcodes5){$shiping_costs = MODULE_SHIPPING_DLY3_COST5;}
	elseif ($order_foo == $zipcodes6){$shiping_costs = MODULE_SHIPPING_DLY3_COST6;}
	elseif ($order_foo == $zipcodes7){$shiping_costs = MODULE_SHIPPING_DLY3_COST7;}
	elseif ($order_foo == $zipcodes8){$shiping_costs = MODULE_SHIPPING_DLY3_COST8;}
	elseif ($order_foo == $zipcodes9){$shiping_costs = MODULE_SHIPPING_DLY3_COST9;}
	elseif ($order_foo == $zipcodes10){$shiping_costs = MODULE_SHIPPING_DLY3_COST10;}

 

But it doesn't work... any I don't know why.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×