im making a small web app as e-commerce site

im storing the product id selected by a visitor into session product id as an array

now what i want to accomplish is:

also store the quantity associated with the product selected

and then update that sessions for quantity if visitor updates the quantity field
of a certain product
lets say in a cart view page

thanks!

Recommended Answers

All 2 Replies

This might help you work out what you need to do

if (!is_array($_SESSION['basket']))
{
	$_SESSION['basket']=array();
}

if (is_array($_POST['qty'])) {
	foreach ($_POST['qty'] as $key=>$quantity) {
		$quantity=ceil($quantity);
		if ($quantity==0) {
			unset($_SESSION['basket'][$key]);
		} else {
			$_SESSION['basket'][$key]['qty']=$quantity;
		}
	}
}

i figured it out. thanks! i use multi dimensional array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.