Zen Cart Logo
Forums / General Questions / Where are cart contents stored?

Where are cart contents stored?

Locked

Views: 2,833

Results 1 to 17 of 17
This thread is locked. New replies are disabled.
2 Jul 2006, 6:56 PM
#1
superprogrammer avatar

superprogrammer

New Zenner

Join Date:
Oct 2004
Posts:
10
Plugin Contributions:
0

Where are cart contents stored?

Say I am browsing through the cart, keep on adding the products. At this stage where are the products stored?
I dont see them in the zen_sessions tables
Thanks

2 Jul 2006, 6:59 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Where are cart contents stored?

If logged in ... you will see them in the customers_basket

If not logged in ... they are burried within the sessions table ...

2 Jul 2006, 7:00 PM
#3
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Where are cart contents stored?

I believe that if you are logged in and creating an order that it is cached until you either checkout or logoff. If you log off without completing checkout the session is saved for your return.

Edit: Ajeh to the rescue!!!

2 Jul 2006, 7:05 PM
#4
superprogrammer avatar

superprogrammer

New Zenner

Join Date:
Oct 2004
Posts:
10
Plugin Contributions:
0

Re: Where are cart contents stored?

Thanks for the reply
I am not logged in
This is what I did

  1. I added few products in my shopping cart (Using Add selected products to cart button)
  2. I truncated the sessions table
  3. I click on Update Cart
  4. Now, if the current cart contents are being read from sessions table, I should nto get any products but to my suprise I do get products and I also got a row added to the sessions table. How did that happen? can anyone explain?
2 Jul 2006, 7:07 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Where are cart contents stored?

You are getting into the grey area of the cache ...

Were you to add to cart and not be able to touch the update cart button when you truncated the session table then that would not happen ...

2 Jul 2006, 7:12 PM
#6
superprogrammer avatar

superprogrammer

New Zenner

Join Date:
Oct 2004
Posts:
10
Plugin Contributions:
0

Re: Where are cart contents stored?

Thanks, you are right
I understood now
Where is the format of sessions defined?
San

2 Jul 2006, 7:33 PM
#7
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,611
Plugin Contributions:
0

Re: Where are cart contents stored?

Perhaps if you told us exactly what you are wanting to do we could point you in the right direction.

2 Jul 2006, 7:51 PM
#8
superprogrammer avatar

superprogrammer

New Zenner

Join Date:
Oct 2004
Posts:
10
Plugin Contributions:
0

Re: Where are cart contents stored?

I am trying to understand the things
When I said
foreach($_SESSION as $key=>$value)
{
echo 'The value of $_SESSION['."'".$key."'".'] is '."'".$value."'".' <br />';
}

Is it because all session info is stored in the database?

Currently the session table has the record:

customers_host_address|s:9:"localhost";cartID|s:0:"";cart|O:12:"shoppingcart":8:{s:8:"contents";a:1:{i:27;a:1:{s:3:"qty";i:1;}}s:5:"total";d:90;s:6:"weight";i:8;s:6:"cartID";s:5:"97814";s:12:"content_type";b:0;s:18:"free_shipping_item";i:0;s:20:"free_shipping_weight";i:0;s:19:"free_shipping_price";i:0;}language|s:7:"english";languages_id|s:1:"1";currency|s:3:"USD";check_valid|s:4:"true";navigation|O:17:"navigationhistory":2:{s:4:"path";a:3:{i:0;a:4:{s:4:"page";s:5:"index";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:5:"cPath";s:2:"18";}s:4:"post";a:0:{}}i:1;a:4:{s:4:"page";s:21:"products_general_info";s:4:"mode";s:6:"NONSSL";s:3:"get";a:3:{s:5:"cPath";s:2:"18";s:4:"sort";s:3:"20a";s:6:"action";s:29:"multiple_products_add_product";}s:4:"post";a:2:{s:11:"products_id";a:10:{i:19;s:1:"0";i:36;s:1:"0";i:37;s:1:"0";i:34;s:1:"0";i:35;s:1:"0";i:23;s:1:"0";i:16;s:1:"0";i:22;s:1:"0";i:12;s:1:"0";i:27;s:1:"1";}s:7:"submit1";s:29:"Add Selected Products to Cart";}}i:2;a:4:{s:4:"page";s:13:"shopping_cart";s:4:"mode";s:6:"NONSSL";s:3:"get";a:1:{s:4:"sort";s:3:"20a";}s:4:"post";a:0:{}}}s:8:"snapshot";a:0:{}}update_expirations|s:4:"true";new_products_id_in_cart|s:0:"";valid_to_checkout|b:1;cart_errors|s:0:"";

  1. Where is it defined that write the sessions in this format?
  2. In which fiile are we doing this and in which file we are parsing the session(if at all)

Thanks

2 Jul 2006, 8:10 PM
#9
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,611
Plugin Contributions:
0

Re: Where are cart contents stored?

Are you wanting to be able to manipulate the information in the cart?

2 Jul 2006, 8:35 PM
#10
superprogrammer avatar

superprogrammer

New Zenner

Join Date:
Oct 2004
Posts:
10
Plugin Contributions:
0

Re: Where are cart contents stored?

Kim:

Are you wanting to be able to manipulate the information in the cart?

Yes and also how can I change this format if required

3 Jul 2006, 6:50 PM
#11
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Where are cart contents stored?

Anyone please answer

5 Jul 2006, 4:33 AM
#12
stevenw721 avatar

stevenw721

New Zenner

Join Date:
Apr 2005
Posts:
9
Plugin Contributions:
0

Re: Where are cart contents stored?

I'm actually looking for this as well, I haven't found anything regarding it here in the forum or in the ZenCart Wiki. Any help would be awesome!

5 Jul 2006, 4:40 AM
#13
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,611
Plugin Contributions:
0

Re: Where are cart contents stored?

If you could expand on exactly what you are wanting to do we could give you a better answer.

5 Jul 2006, 4:44 AM
#14
stevenw721 avatar

stevenw721

New Zenner

Join Date:
Apr 2005
Posts:
9
Plugin Contributions:
0

Re: Where are cart contents stored?

I'm trying to find a way of making a custom form (that holds up to 12 items with attributes at a time) submit to a cart like a regular item would. If I knew where that form with the "action=add_product" went and actually did the magic of adding it to a cart i think i could figure the rest out.

The form is online here if you'd like to see what i'm trying to accomplish. http://205.234.206.236/store/order.php

6 Jul 2006, 3:31 PM
#15
stevenw721 avatar

stevenw721

New Zenner

Join Date:
Apr 2005
Posts:
9
Plugin Contributions:
0

Re: Where are cart contents stored?

I've combed through every file I thought would be related to adding items to the cart and cannot for the life of me figure out where it's done. Basically i'm trying to make an Amazon - like cart system with the marker at the top displaying what step a person is on. The start of my endeavor is still located at http://205.234.206.236/store/order.php if anyone would like to take a look.

Also, sorry for the double post but i'm getting desperate.

6 Jul 2006, 3:39 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Where are cart contents stored?

"How" things are stored in the sessions table is of 0 relavance to using it from your stand point ...

You need to ensure that as you move from page to page that your input data travels with you ...

If you look at any of the pages such as contact_us ...

Look at how the files in:
/includes/modules/pages/contact_us/.

/includes/templates/templates_default/templates/tpl_contact_us_default.php

/includes/languages/english/contact_us

all interact with one another ...

To see something more verbose ... look at the same paths but for login and create_account

To see how to get information to move betweeen pages ... look at the checkout_blah files ... and follow the $_SESSION['comments'] and $comment ...

The point is ... I do not need to know "How" the $_SESSION['comments'] is stored in the session table ... I just need to use the submit and variables and input fields etc. correctly and all of that is managed for me as to the storage in the session table ...

6 Jul 2006, 6:50 PM
#17
stevenw721 avatar

stevenw721

New Zenner

Join Date:
Apr 2005
Posts:
9
Plugin Contributions:
0

Re: Where are cart contents stored?

OK, then my question now is how do I make the form in the page i linked to above add all the products to the $_SESSION[cart] with the selected attributes?

From my searching and tinkering with the cart i've only figured out how to add one product at a time with attributes or multiple products without attributes. This form requires me to be able to add multiple products each with it's own attributes.

I've found the functions in the classes/shopping_cart.php document but I don't see a way to add more than one at a time with attributes.