If I change the code to:
if(strpos($methodName, '2nd') !== false and $exclude_gnd!==0){
if($twoDayZone != '-')
{
$baseShippingCost = us_get_cost_for_lbs_and_zone('ups_commus48_2da', $evalWeight, $twoDayZone);
$shipDiscount = $shippingDiscounts['second'];
}/*elseif($twoDayZone = '-'){$baseShippingCost = 0;}*/
else {$baseShippingCost = 0;}
}
else {$baseShippingCost = 0;}
it works better, BUT I am faced with another problem...I need to go a step further. I am actually using 4 IF statements in sequence like the one above. They look like this:
$exclude_gnd=1;
/* a little bit of searching through the name
to find out what kind of shipping to use */
if(strpos($methodName, 'ground') !== false and $exclude_gnd!==0){
if($groundZone != '-'){
$baseShippingCost = us_get_cost_for_lbs_and_zone('ups_commus48_gnd', $evalWeight, $groundZone);
$shipDiscount = $shippingDiscounts['ground'];
}/*elseif($groundZone = '-'){$baseShippingCost = 0;}*/
else{$baseShippingCost = 0; }
}
else{$baseShippingCost = 0; }
if((strpos($methodName, 'overnight') !== false or strpos($methodName, "next day") !== false) and $exclude_gnd!==0){
if($overNightZone != '-'){
$baseShippingCost = us_get_cost_for_lbs_and_zone('ups_commus48_1da', $evalWeight, $overNightZone);
$shipDiscount = $shippingDiscounts['overnight'];
}/*elseif($overNightZone = '-'){$baseShippingCost = 0;}*/
else{$baseShippingCost = 0; }
}
else{$baseShippingCost = 0; }
if(strpos($methodName, '2nd') !== false and $exclude_gnd!==0){
if($twoDayZone != '-')
{
$baseShippingCost = us_get_cost_for_lbs_and_zone('ups_commus48_2da', $evalWeight, $twoDayZone);
$shipDiscount = $shippingDiscounts['second'];
}/*elseif($twoDayZone = '-'){$baseShippingCost = 0;}*/
else {$baseShippingCost = 0;}
}
else {$baseShippingCost = 0;}
if(strpos($methodName, '3 day') !== false and $exclude_gnd!==0){
if($threeDayZone != '-'){
$baseShippingCost = us_get_cost_for_lbs_and_zone('ups_commus48_3ds', $evalWeight, $threeDayZone);
$shipDiscount = $shippingDiscounts['third'];
}/*elseif($threeDayZone = '-'){$baseShippingCost = 0;}*/
else{$baseShippingCost = 0; }
}
else{$baseShippingCost = 0; }
/*else{
$baseShippingCost = $groundCost;
}*/
$tempArr = array($baseShippingCost, $methodName, $shipDiscount);
return $tempArr;
}
The problem I have now is the ELSE statement at the end of each code block, such as:
if(strpos($methodName, '2nd') !== false and $exclude_gnd!==0){
if($twoDayZone != '-')
{
$baseShippingCost = us_get_cost_for_lbs_and_zone('ups_commus48_2da', $evalWeight, $twoDayZone);
$shipDiscount = $shippingDiscounts['second'];
}/*elseif($twoDayZone = '-'){$baseShippingCost = 0;}*/
/*else {$baseShippingCost = 0;}*/
}else {$baseShippingCost = 0;}
is interfering with previous IF code blocks. (writting values to the previous IF statements). Can you tell me how to change my code so this will not happen (it is obvious that I have something wrong :-( )? I NEED TO ISOLATE EACH "ELSE {$baseShippingCost = 0;}" STATEMENT TO THE IF STATEMENT IT IS ASSOSICATED WITH.
BTW...my objective here in this code is to create a drop down list (created from other code that the results of this code is passed to) on a shopping cart. There are 4 shipping methods represented here (ground, overnight, second day and 3 day deliveries). After I finish this part of the script, I will be creating other variables similar to the "$exclude_gnd" variable above that will be used to (in the long run) notify the user if a shipping method is not available.