Page 1 of 1
Where is Cart data/items stored?
Posted: Thu Mar 10, 2011 4:52 am
by RJonesUSC
Initially, from reading other threads, I thought that items, qty cart data was being saved in a cookie. Is this correct or is it being stored in the database somewhere? Just today I logged into a computer that I hadn't used before and logged in and there were already items in my cart - items that I had added when using another workstation.
Is the cart info located in the database somewhere and if so, what table?
Thanks in advance.
Re: Where is Cart data/items stored?
Posted: Fri Mar 11, 2011 5:32 am
by RJonesUSC
OK, I see where it's stored in the db - duh. Can someone decode the syntax of how the data is stored in the field? Here are a couple examples of cart records:
Code: Select all
a:3:{i:49;i:100;i:55;i:10;i:59;i:10;}
the a I have no idea. The 1 and 3 at the beginning looks to be the number of cart items. It looks like in the top cart there's qty 20 of item #69. The second cart looks to have 100xitem#49, 10xitem#55 and 10xitem#59.
None of those use options but they all use discount pricing. Is that info stored in there or somewhere else or is the db being queried every time to display the correct pricing information?
What are the i's for?
Re: Where is Cart data/items stored?
Posted: Fri Mar 11, 2011 6:17 am
by Qphoria
php has a function called "serialize"
It basically takes an array and combines it into 1 line... kinda like a zip file
Similarly, you can unzip or "unserialize" that
But still even when unserialized it probably won't make much sense to you.
It is basically the product id, the options, and the qty
Re: Where is Cart data/items stored?
Posted: Fri Mar 11, 2011 6:32 am
by RJonesUSC
Qphoria wrote:php has a function called "serialize"
It basically takes an array and combines it into 1 line... kinda like a zip file
Similarly, you can unzip or "unserialize" that
But still even when unserialized it probably won't make much sense to you.
It is basically the product id, the options, and the qty
Qphoria, thanks for the reply. It could make sense to me. I figured out the qty and product id, didn't I?
Is discount in there anywhere? In my setup, all prices are using a discount of some sort. Or is the DB queried every time to check to a discount whenever the cart prices are displayed?
I'm really looking to display the cart contents on a page outside of the OC system. I've gotten as far as getting the customer and their cart contents and qty but not prices. I could always just query the db to get the info but I was hoping the prices were stored elsewhere, possibly in the cart record. But it doesn't look like that's the case. Is that correct?
Re: Where is Cart data/items stored?
Posted: Fri Mar 11, 2011 7:00 am
by Xsecrets
RJonesUSC wrote:Qphoria wrote:php has a function called "serialize"
It basically takes an array and combines it into 1 line... kinda like a zip file
Similarly, you can unzip or "unserialize" that
But still even when unserialized it probably won't make much sense to you.
It is basically the product id, the options, and the qty
Qphoria, thanks for the reply. It could make sense to me. I figured out the qty and product id, didn't I?
Is discount in there anywhere? In my setup, all prices are using a discount of some sort. Or is the DB queried every time to check to a discount whenever the cart prices are displayed?
I'm really looking to display the cart contents on a page outside of the OC system. I've gotten as far as getting the customer and their cart contents and qty but not prices. I could always just query the db to get the info but I was hoping the prices were stored elsewhere, possibly in the cart record. But it doesn't look like that's the case. Is that correct?
no prices are not stored anywhere for the cart. only the product id the qty and the options. everything else is queried each time.
Re: Where is Cart data/items stored?
Posted: Fri Mar 11, 2011 7:03 am
by RJonesUSC
Xsecrets, thanks for the clarification. Now I know how I need to proceed.
Re: Where is Cart data/items stored?
Posted: Thu Apr 21, 2011 5:13 pm
by armadillocreative
i'm obviously blind but what table stores the cart info?
Re: Where is Cart data/items stored?
Posted: Thu Apr 21, 2011 10:14 pm
by RJonesUSC
armadillocreative wrote:i'm obviously blind but what table stores the cart info?
In the "customer" table there is a field named "cart".
Re: Where is Cart data/items stored?
Posted: Wed Sep 18, 2013 11:31 pm
by oyuka
I am new to opencart and I want to know in which table the cart items are stored wen an user is not logged in and before the checkout?

Re: Where is Cart data/items stored?
Posted: Thu Sep 19, 2013 12:47 am
by RJonesUSC
oyuka wrote:I am new to opencart and I want to know in which table the cart items are stored wen an user is not logged in and before the checkout?

Check out the post right above yours.

Re: Where is Cart data/items stored?
Posted: Thu Sep 19, 2013 1:23 am
by Qphoria
Just to note, the data in the "cart" field is serialized so you'll have to unserialize it first
Re: Where is Cart data/items stored?
Posted: Thu Mar 24, 2016 4:29 am
by adriankoooo
A quick question: how long is stored the cart data in 1.5.x?
Re: Where is Cart data/items stored?
Posted: Thu Mar 24, 2016 10:10 pm
by Qphoria
adriankoooo wrote:A quick question: how long is stored the cart data in 1.5.x?
1.x-2.0.x the cart is serialized and stored indefinitely in the customer table under the "cart" column
2.1.x+ the cart has its own table now but is still stored indefinitely.