Removing array element does not work
there is a $_SESSION array that holds the ID of user's currently selected
products (which are in the cart). Now, when the user sees his bill, he
want to remove an item (product) from his cart, I have put him a link to
do so. but the script does not work. I have configured a $_GET['itemid']
in the URL and by using it, I unset() that array element.
BUT it does not work. What should I do? Here is my code
function remove_from_cart($stack_id) // stack_id is the id of the item in
cart array ($_SESSION)
{
for($i=0; $i < count($_SESSION['add-to-cart-item']); $i++)
{
if($_SESSION['add-to-cart-item'][$i] == $stack_id)
{
unset($_SESSION['add-to-cart-item'][$stack_id]);
}
}
}
No comments:
Post a Comment