Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Associated Array - shopping cart

Status
Not open for further replies.

rvr1

Programmer
Feb 6, 2004
16
NL
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 :eek:)
 
I think if you simply print_r( $_SESSION ) after you session_start(), you'll see how to manipulate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top