Answer
Apr 09, 2013 - 05:08 AM
if (!isset($_SESSION['cart'])) { $_SESSION['cart'] = array(); $_SESSION['cart']['pid'][] = $pid; $_SESSION['cart']['pid']['price'] = $price; $_SESSION['cart']['pid']['quantity'] = $quantity; $_SESSION['cart']['total_price'] = $price; $_SESSION['cart']['total_items'] = $quantity; }elseif(array_key_exists($pid, $_SESSION['cart'])){ //increase price //increase quantity }else{ $_SESSION['cart']['pid'][] = $pid; $_SESSION['cart']['pid']['price'] = $price; $_SESSION['cart']['total_price'] += $price; $_SESSION['cart']['total_items'] += $quantity; }
Add New Comment