Canman2005 Posted August 7, 2009 Share Posted August 7, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/169268-solved-removing-1-from-session/ Share on other sites More sharing options...
mikesta707 Posted August 7, 2009 Share Posted August 7, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/169268-solved-removing-1-from-session/#findComment-893222 Share on other sites More sharing options...
Canman2005 Posted August 7, 2009 Author Share Posted August 7, 2009 I think that did it, thanks Quote Link to comment https://forums.phpfreaks.com/topic/169268-solved-removing-1-from-session/#findComment-893238 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.