Accessing cart contents


(Joel Porgand) #1

Is there a means to pull out information of the current state of a cart (ie. like # items contained) from another page? Like a session var or similar?


(Bart Banda) #2

The simplest way to do it is to just use a cart asset specifically just for printing the right data you need: http://manuals.matrix.squizsuite.net/e-commerce/chapters/cart

 

You can then customise the bodycopy with any of the keywords,and include it on a page by either nesting it in, using %globals_asset_contents_raw:1234%, or ajaxing it in via JS.

 

Does that help?


(Joel Porgand) #3

The simplest way to do it is to just use a cart asset specifically just for printing the right data you need: http://manuals.matrix.squizsuite.net/e-commerce/chapters/cart

 

You can then customise the bodycopy with any of the keywords,and include it on a page by either nesting it in, using %globals_asset_contents_raw:1234%, or ajaxing it in via JS.

 

Does that help?

 

well I also want to use it as a normal cart, so setting up a separate cart won't work (at least, I think not?). 

 

I think I've solved my own issue though, I set up a user defined paint layout & a user defined design on the cart to render it as json so I can query it via ajax with http://path.to/cart?SQ_PAINT_LAYOUT_NAME=status&SQ_DESIGN_NAME=json


(Bart Banda) #4

 

well I also want to use it as a normal cart, so setting up a separate cart won't work (at least, I think not?). 

 

Sure it will, you can have as many cart assets as you want, they will all source cart data from the current session. Done this on a couple of projects. 


(Joel Porgand) #5

 

Sure it will, you can have as many cart assets as you want, they will all source cart data from the current session. Done this on a couple of projects. 

 

Hrm. This line from the doco led me to believe they operated independently of one another:

 

 

 When configuring an e-commerce system, multiple Carts can be used on aSite to give users greater control over their purchases. More than one e-commerce Cart will allow users to add items to a number of different Carts, completing the payment of the contents of each Cart individually.

 

The fact that the asset selection/asset target points at a specific cart seems to fit that description?


(Bart Banda) #6

That's interesting, never seen that line before. There might be some configuration where you specify the cart to act completely separately, or vice versa. I guess the only way to find out what the default is, is to try. We might need to update that line in the manuals as well... 


(Joel Porgand) #7

That's interesting, never seen that line before. There might be some configuration where you specify the cart to act completely separately, or vice versa. I guess the only way to find out what the default is, is to try. We might need to update that line in the manuals as well... 

 

Clarity is always nice :)

 

Thanks for your responsiveness Bart.


(Chiranjivi Upreti) #8

 

Sure it will, you can have as many cart assets as you want, they will all source cart data from the current session. Done this on a couple of projects. 

 

Looking at the code, the cart will source the cart data from the session based on the cart's checkout asset. So if multiple carts have got same checkout asset set then they will source same cart data. However if the carts has different checkout asset, then each will have their own set of cart data in the session.

 

So basically checkout asset set on the cart determines which set of cart data to source from the session. Same applies when setting the cart session data.