adding additional items in a ecommerce application to save in session
i want to use this site as a reference to explain what im trying to figure out. 开发者_开发知识库http://www.shop-script.com/demo/store/index.php?lang=eng
if you select a product then enter a value higher than 1 for the quantity of a product that you want then press add to cart. i know that this information goes into a session but how is it added?
what i do know is say a session named cart is created or exists and the products id is inserted into the session to look like something like this:
$_SESSION['cart'] = "100" //product id
how can i insert the amount of quantities that were entered on the products detail page? that is one thing that is confusing me. thanks
Just use the product ID as a key in a session variable holding the quantity:
$item_id = 1000;
$_SESSION['item_id'] = $item_id;
$_SESSION[$item_id]['quantity'] = 10; // Set quantity to 10
精彩评论