Having a bad day trying to check through the $_SESSION["cart_array"] to see if the product ID in question has associated extras (over 100 different colours to choose from). If it does and it's already evident in the basket, it needs to add to quantity, otherwise be added as a new product. At the moment everything is adding as a new product, even if it exists in the first place.
I know I'm trying to manipulate the $_SESSION object incorrectly, but I don't know how to get it to echo anything but "A
Sorry to be a putz!
I know I'm trying to manipulate the $_SESSION object incorrectly, but I don't know how to get it to echo anything but "A
PHP:
// RUN IF THE CART HAS AT LEAST ONE ITEM IN IT
foreach ($_SESSION["cart_array"] as $each_item) {
$i++;
while (list($key, $value) = each($each_item)) {
if (($key == "item_id" && $value == $pid) && ($key == "item_extratype" && $value == $extype) && ($key == "item_extra" && $value == $ext)) {
// That item is in cart already so let's adjust its quantity using array_splice()
array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "item_extratype" => $extype, "item_extra" => $ext, "quantity" => $each_item['quantity'] + 1)));
$wasFound = true;
} // close if condition
} // close while loop
} // close foreach loop
if ($wasFound == false) {
array_push($_SESSION["cart_array"], array("item_id" => $pid, "item_extratype" => $extype, "item_extra" => $ext, "quantity" => 1));
}
Sorry to be a putz!