I have a shopping cart using oo design. I have a cart object that holds cart items. Those items have typical properties id, name, price, qty, etc. I also added a new property called category. I created a function to loop through the cart and create an array of categories.
I am taking that array now to determine the shipping and handling. Items with a category of "Stickers" are not charged. The base shipping price is $3.95. Looping through the category array the shipping price is incremented by $1 for every non-sticker category item.
here is my code snippet:
<?php
if($CART->getMax() == 1){
$sh = 3.95;
}elseif($CART->getMax() > 1){
$sh = 3.95;
$catItem = $CART->getCategory();
foreach ($catItem as $temp){
if($temp == "Stickers"){
//echo($temp);
$sh += 0;
}
else{
$sh += 1;
}
}
}
$CART->recalc_total($sh);
?>
It loops through the array but adds a $1 to the shipping when it is a "Stickers". Do I have my control structure set up wrong? Any help would be greatly appreciated.
thx
alex