I am setting up a basic shopping cart and at present I have the folowing code to store the product_id and quantity of those items which the customer has added to the basket:
$product_details = array("qty" => $quantity, "productID" => $product_id);
if(isset($_SESSION['cart'][$product_id]))
{
$_SESSION['cart'][$product_id]['qty']+=$product_details['qty'];
}
else
{
$_SESSION['cart'][$product_id]=$product_details;
}
I know this may sound a silly question, but how do I access items that have been saved to the $_SESSION['cart'] array?
Basically, what I need to do is:
1. Loop though the array and recall the stored product ID's so that the corrasponding data can be extracted from the database
2. Delete an item
3. Update the quantity
Any help is greatly appreciated.
Thanks )
$product_details = array("qty" => $quantity, "productID" => $product_id);
if(isset($_SESSION['cart'][$product_id]))
{
$_SESSION['cart'][$product_id]['qty']+=$product_details['qty'];
}
else
{
$_SESSION['cart'][$product_id]=$product_details;
}
I know this may sound a silly question, but how do I access items that have been saved to the $_SESSION['cart'] array?
Basically, what I need to do is:
1. Loop though the array and recall the stored product ID's so that the corrasponding data can be extracted from the database
2. Delete an item
3. Update the quantity
Any help is greatly appreciated.
Thanks )