Page 1 of 2
[REQUEST] Disable shopping cart saving [SOLVED]
Posted: Thu Sep 01, 2011 6:29 am
by AnonyMoose
Some of my customers are confused by shopping cart being saved when they log off. Basically, customer adds items to the basket, decides not to buy and logs off, most of them don't bother to read message explaining cart being saved or simply forget about it soon.
Same customer comes back in few days/weeks/months, adds items to the shopping cart and when he logs in on the checkout page to complete transaction, discovers extra items added to current cart from previous saved session.
Most customers use Wish List if they want to save items for later anyway, so it would be good to have ENABLE/DISABLE option for this function in the Admin panel.
Re: [REQUEST] Disable shopping cart saving
Posted: Wed Sep 07, 2011 5:00 am
by wakabayashi
Yes I have exactly the same problem! Does anybody have a solution for this mistake?
Re: [REQUEST] Disable shopping cart saving
Posted: Wed Sep 07, 2011 6:39 am
by Xsecrets
wakabayashi wrote:Yes I have exactly the same problem! Does anybody have a solution for this mistake?
it's not a mistake it's a design decision.
Re: [REQUEST] Disable shopping cart saving
Posted: Wed Sep 07, 2011 9:39 am
by mberlant
It's wonderful to learn that it is a design element instead of a mistake. That does not make it any more desirable.
I would now like to join the chorus in asking how to reverse this behavior, so that the cart gets emptied out at the end of any incomplete session.
Re: [REQUEST] Disable shopping cart saving
Posted: Wed Sep 07, 2011 7:02 pm
by uksitebuilder
It is the way most carts work tbh.
I agree that it is a little irritating. I have been irritated by it many times when testing a site/account
As a fix, I propose that the cart be emptied after a specified cart lifetime.
The cart data is stored in the 'customer' table in the 'cart' column
Unfortunately, there is no 'last_login' date/time or 'last_action' date/time column in the table which would have been ideal to be used as a point in time from which to empty their cart.
So, this would need to be added and a function added to the login function (or index.php if logging last action) to update the the new column in the database.
Then finally either a cron job should be run hourly (or whenever) or script attached to index.php/startup.php to run a secondary script to empty the carts where the data/time in our new column is older than the time we specify as the cart lifetime.
Re: [REQUEST] Disable shopping cart saving
Posted: Thu Sep 08, 2011 10:14 pm
by mberlant
uksitebuilder wrote:It is the way most carts work tbh.
That's not my experience when shopping at any of the larger online enterprises, but your comment and my reply get neither of us closer to a solution.
uksitebuilder wrote:Unfortunately, there is no 'last_login' date/time or 'last_action' date/time column in the table which would have been ideal to be used as a point in time from which to empty their cart.
As I was pondering how to flesh out your suggestion, I had an epiphany. The best way to implement your suggestion is by not implementing your suggestion. As it turns out, we don't really care why or how long ago the customer abandoned the cart.
While we do not have any way of knowing how long a customer has been idle, we do know specifically when to trash the cart the customer abandoned after his last session. The time to trash the abandoned cart is whenever the customer is required to log in anew.
At the time of customer login his "customer cart" should be flushed prior to moving his "unknown customer session cart's" contents, if any, into the "known customer cart" for continued shopping and/or checkout.
Or, am I missing something here?
Re: [REQUEST] Disable shopping cart saving
Posted: Thu Sep 08, 2011 11:11 pm
by uksitebuilder
Hey, I thought really long and hard about my suggestion lol
It's difficult to answer one post on these forums and spend anymore time than 5 minutes on it.
I just usually go with my brain first thrashes out otherwise I would spend all day and night on here (instead of just all day)
BUT, your solution sounds better to flush the cart on login.
i thought it would be as simple as doing the following, but must be missing something somewhere
in system/library/customer.php
find
add after
Code: Select all
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '' WHERE customer_id = '" . $customer_query->row['customer_id'] . "'");
Re: [REQUEST] Disable shopping cart saving
Posted: Thu Sep 08, 2011 11:46 pm
by mberlant
Great! I will use your snippets of code to try to get further -- when my brain is less foggy. Thanks.
Re: [REQUEST] Disable shopping cart saving
Posted: Thu Sep 22, 2011 4:42 am
by AnonyMoose
Any chance you figured out how to solve this? I'll owe you a pint if so! :-)
Re: [REQUEST] Disable shopping cart saving
Posted: Fri Sep 23, 2011 8:40 pm
by j8yba
its doesnt work for me. items still there.
Re: [REQUEST] Disable shopping cart saving
Posted: Fri Sep 23, 2011 8:49 pm
by j8yba
My bad, actually it does work with this proper explanation...
find...
Code: Select all
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '" . $this->db->escape(serialize($this->session->data['cart'])) . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int)$this->session->data['customer_id'] . "'");
and replace with...
Code: Select all
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '' WHERE customer_id = '" . $customer_query->row['customer_id'] . "'");
thats worked for me anyway!
HTH
Re: [REQUEST] Disable shopping cart saving
Posted: Sun Sep 25, 2011 4:58 am
by AnonyMoose
Works fine now, thanks to both of you for helping!
Should I add [solved], or leave thread open as it's my next version feature request?
Re: [REQUEST] Disable shopping cart saving
Posted: Sun Sep 25, 2011 8:00 am
by mberlant
I think I would add [SOLVED] after [REQUEST] to show that both indicators are active, and that there is code available to work into the new release.
I would also like to add how pleased I am that four forum members built upon each other's thoughts to arrive at a workable solution in such a short time. Sorry to contradict you, Simon, but spilling your incomplete thoughts when you did was just the spark we needed.
Cheers.
Re: [REQUEST] Disable shopping cart saving
Posted: Sun Sep 25, 2011 6:22 pm
by uksitebuilder
That's what the community is for.
I found the general area and tbh was waiting for your solution as I thought you had it in hand

Re: [REQUEST] Disable shopping cart saving [SOLVED]
Posted: Tue Oct 04, 2011 6:05 am
by AnonyMoose
Once you've done it, it's worth changing logout message in catalog\language\english\account\logout.php so it doesn't say 'your cart has been saved'..
Re: [REQUEST] Disable shopping cart saving [SOLVED]
Posted: Tue Oct 04, 2011 3:52 pm
by mberlant
AnonyMoose wrote:Once you've done it, it's worth changing logout message in catalog\language\english\account\logout.php so it doesn't say 'your cart has been saved'..
Good catch. It is always a good idea to tidy up. I didn't think of this in this case because I don't think I have found myself ever, nor observed anyone else ever, pushing the "Log out" button instead of simply abandoning the page.
Re: [REQUEST] Disable shopping cart saving [SOLVED]
Posted: Tue Oct 04, 2011 5:00 pm
by j8yba
Cant believe this isnt a feature by default anyway!
Re: [REQUEST] Disable shopping cart saving [SOLVED]
Posted: Tue Oct 04, 2011 7:17 pm
by AnonyMoose
j8yba wrote:Cant believe this isnt a feature by default anyway!
I guess it makes sense in some cases, Amazon for example does it and I quite often add some books to the cart, come back after few days and add more to buy them all etc, but I'd rather have option of disabling it.
It would be nice to have some cookies keeping cart for a day or something though, so it won't get empty every time customer closes his browser.
Re: [REQUEST] Disable shopping cart saving [SOLVED]
Posted: Tue Oct 04, 2011 7:36 pm
by werepair
After reading this thread i have now made a vQmod file for 1.5.1.3 if anyone wants it,
all i have done is made the vQmod file "the mod is not my work"
you will also see this message when you logout
Account Logout
You have been logged off your account. It is now safe to leave the computer.
Your shopping cart has not been saved.
best regards
Re: [REQUEST] Disable shopping cart saving [SOLVED]
Posted: Tue Oct 04, 2011 7:43 pm
by j8yba
werepair wrote:You have been logged off your account. It is now safe to leave the computer.
Is this a normal exit quote? "safe to leave the computer" ? Surely safe to leave this website or something would be better?