raptor30506090 Posted June 30, 2012 Share Posted June 30, 2012 Hi guys Im trying to unset a session in my cart but it returns ?0.00 even when there is more items in the cart any help please <?php switch ($action){ case "add": if(isset($_SESSION['cart'][(int)$id])){ $_SESSION['cart'][(int)$id]++; }else{ $_SESSION['cart'][(int)$id] = 1; } break; case "remove": if(isset($_SESSION['cart'][(int)$id])){ $_SESSION['cart'][(int)$id]--; if($_SESSION['cart'][(int)$id] == 0){ unset($_SESSION['cart'][(int)$id]); } } break; case "empty": if(isset($_SESSION['cart'][(int)$id])){ unset($_SESSION['cart'][(int)$id]); } break; }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/265034-unset/ Share on other sites More sharing options...
PeoMachine Posted June 30, 2012 Share Posted June 30, 2012 i didnt understand what youre trying to do... if you wanna unset all in the 'cart' index, just do a $_SESSION['cart'] = array(); Quote Link to comment https://forums.phpfreaks.com/topic/265034-unset/#findComment-1358127 Share on other sites More sharing options...
raptor30506090 Posted June 30, 2012 Author Share Posted June 30, 2012 Hi what im trying to do is unset one item at a time as they put lower quantity in cart to 0 but when i do this it leaves a 0.00 as price in the session cart and dont display the other items when i go back to products page again adds item again then all items show Quote Link to comment https://forums.phpfreaks.com/topic/265034-unset/#findComment-1358137 Share on other sites More sharing options...
raptor30506090 Posted June 30, 2012 Author Share Posted June 30, 2012 Solved this problem with an if statment thanks Quote Link to comment https://forums.phpfreaks.com/topic/265034-unset/#findComment-1358140 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.