Welcome Guest, Not a member yet? Register   Sign In
Problem with $this->cart->remove($rowid)
#1

Hi. I think that I have a problem with sessions. I use $this->cart->remove($rowid); But when I updating a list of items in cart with $this->cart->contents() I see the deleted row. After a few minutes line disappears.
Reply
#2

Sounds like a caching issue or you are redisplaying the items before the delete is actually performed. Hard to know with only a description and no code to follow. The 'remove' method returns true/false. Do you test for that result before continuing with the code?
Reply
#3

Actually, unless something prevents remove() from returning, it returns true regardless of the outcome. The underlying _save_cart() returns true/false, but even that doesn't indicate an error, it just indicates whether the cart was empty (false) or still contains more items (true) after removing the item.

Although the session is used to persist the cart, it shouldn't really be an issue with the steps described here. When you call remove() the Cart library modifies an internal property which holds the contents of the cart, then sets the session. When you call contents(), it doesn't touch the session. In fact, it only reads from the session when you load the library.

One questionable item, though, is the way the session library is loaded by the Cart library's constructor...
Reply




Theme © iAndrew 2016 - Forum software by © MyBB