seaweed Posted June 25, 2010 Share Posted June 25, 2010 Can anyone point out why this isn't incrementing the qty of items already in the cart? Maybe it's a Friday Brain Fart... session_start(); if (isset($_SESSION['CART']) == false || isset($_SESSION['CART']['ITEMS']) == false) { $_SESSION['CART']['ITEMS'] = array(); } foreach ($_POST AS $sku => $qty) { if (!empty($qty)) { // if the product sku is already in the cart, do this // foreach ($_SESSION['CART']['ITEMS'] as $cart_item => $item) { if ($item['item_sku'] == $sku) { $_SESSION['CART']['ITEMS'][$cart_item]['item_qty'] = $_SESSION['CART']['ITEMS'][$cart_item]['item_qty'] + $qty; $found = true; break; } } // if the product sku is not already in the cart, do this // if (!$found) { $_SESSION['CART']['ITEMS'][] = array('item_sku' => $sku, 'item_qty' => $qty); } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.