Hello,
I'm working on a shopping cart using an array stored in a session. i've got it working so that I can add a product to it but when I add a second product it overwrites the existing item. I think it must be something to do with needing nesting arrays?
Please can anyone help?
my code so far is:
if ($POST['id']=="")
{}
else
{
if(isset($SESSION['cart']))
{
$SESSION['cart'] = array("item1" => array("prodId" => $id,
"prodName" => $prod,
"prodSize" => $size,
"prodPrice" => $price,
"prodBrand" => $brand,
"prodQty" => 1));
$SESSION['cart'];
}
else
{
$_SESSION['cart'] = array("prodId" => $id,
"prodName" => $prod,
"prodSize" => $size,
"prodPrice" => $price,
"prodBrand" => $brand,
"prodQty" => 1);
}
}