Jump to content

Simple PHP shopping cart


edgustaf

Recommended Posts

don't know but i think try this part of what you have not sure but give it a try

 

if($_SESSION['cart']) {
	$product_id=0;
	switch($action) {
		case "add":
                        $product_id++;
			if (isset($_SESSION['cart'][$product_id])){ 
          				 $_SESSION['cart'][$product_id];}
         			else 
           						{$_SESSION['cart'][$product_id]=1;}
            break;

		case "remove":
                        $product_id = $product_id -1;
			if (isset($_SESSION['cart'][$product_id]))
					 $_SESSION['cart'][$product_id];
					 if ($_SESSION['cart'][$product_id]==0)
					 	unset($_SESSION['cart'][$product_id]);
		break;

		case "empty":
			unset($_SESSION['cart']);  
		break;
		}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.