Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.