I have struggled to find a solution to a simple shopping cart with $_SESSION
.
I kept it very simple and this is my code right now
if ( Input::isPos
A better way of doing it would be to create another array called sizes
and store sizes there. So your code would look something like
if (in_array($size, $_SESSION['cart'][$id]['sizes'])) {
//The size has been added to the cart
} else {
//The size isn't in the cart so add it
$_SESSION['cart'][$id]['sizes'][] = $size;
}
Also rather than store the quantity like
$_SESSION['cart'][$id][1]+=$qta;
Why don't you have more meaningful keys so you can understand the contents of the array better. For example
$_SESSION['cart'][$id]['qty']+=$qta;