Shopping Cart Session to keep track of distinct items

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fitchic77
Forum Commoner
Posts: 51
Joined: Thu Jul 20, 2006 11:57 pm

Shopping Cart Session to keep track of distinct items

Post by fitchic77 »

Each item needs to be distinct due to size and quantity and Product ID. Is there a better way to store a distinct set of data. Right now I'm concatinating the below information (product id, size and quantity) and parsing them out later.

Code: Select all

$_SESSION['products']["idProduct_".$id."_size|".$size . "_qty:" .$qty]  =  $id; //new entry
thanks,
Andrea
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your closing

Code: Select all

tag was an opening one.

Code: Select all

...

Code: Select all

$_SESSION['products'][] = array('id' => $id, 'size' => $size, 'qty' => $qty);
Post Reply