Jump to content

cart implementation


LostKobrakai
 Share

Recommended Posts

Im currently working on a project which involves a small simple shop. Currently I'm storing the information about cart entries in the session as array or for logged in users in a repeater. But I wanted a single way to add/update the cart instead of handling both cases all the time. By now I've two functions which convert the session array to a PageArray and the back to a phparray again, so I can just add/update the repeateritems/sessionitems in a single way throughout the page. Now I wanted to know what others might think about this? Would using a class, instead of loose functions, be useful there?

Another way could be to have a single page with just the repeaterfield for the cart for each session. These would be cleaned up after max. session lifetime.

Link to comment
Share on other sites

I would look at storing the cart and its contents as pages, with just a reference to the cart page(s) in the session or their user page. You could either use a parent-and-child relationship for these, or repeaters - best choice will depend on complexity of products I suppose :)

This way, the "content" of the cart is always stored in the database using a consistent format, and you are just keeping a small reference to it where it's needed so you can easily get it.

I would tie it all together using a module to handle just the cart itself - adding/removing items, setting/getting the reference to it with the session/user property or whatever.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...