Jump to content

[SOLVED] Removing 1 from session


Canman2005

Recommended Posts

Hi all

 

I have the following function

 

function remove($id)
{
if(!$this->is_item_in_basket($id)) return false;
$_SESSION['cart']['items'][$id]['quantity'] --;
return true; 
}

 

which when run is supposed to remove 1 from a qty of a particular products, so if the quantity is 8 and it's run, it's supposed to remove 1 making that 7

 

But at the moment it seems quite random, sometimes it takes off 1 from the quantity and sometimes it takes the quanity down to 0

 

Any ideas?

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/169268-solved-removing-1-from-session/
Share on other sites

looks fine to me. Try deleting the space between the decrement operator and the variable, IE

 

$_SESSION['cart']['items'][$id]['quantity']--;

 

other than that I dont really see a problem. Althought Im not sure what the is_item_in_basket method does, or if that could be impacting things

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.