millercj Posted July 31, 2008 Share Posted July 31, 2008 Hi Everyone, I've been charged with creating my own shopping cart (which i have never done), and i'm not sure how exactly one works or where data is stored on the backend. My ultimate goal would be to create something like http://www.panic.com/goods/ but i know that is well beyond my know-how at this point. I'm looking for information mainly on what happens as a person is shopping and selecting products to buy (before completing a sale). Are they saved in a database, cookies, how and where are they manipulated? Quote Link to comment https://forums.phpfreaks.com/topic/117597-shopping-cart-design/ Share on other sites More sharing options...
discomatt Posted July 31, 2008 Share Posted July 31, 2008 A custom session-like combination using a database/cookie system would probably be the ideal way to store the cart information. Research into the way PHP handles sessions, and it should give you a good framework to design your cart system around. Basically, you store a single cookie on the user's machine with a hard-to-guess ID. You then store this id along with any products the user will add to his cart in a database. When the user visits his cart, grab all relevant data from the db where the id matches his cookie. Voila! Quote Link to comment https://forums.phpfreaks.com/topic/117597-shopping-cart-design/#findComment-604895 Share on other sites More sharing options...
millercj Posted July 31, 2008 Author Share Posted July 31, 2008 Great! Thanks, I just wasn't sure of best practices on this stuff Quote Link to comment https://forums.phpfreaks.com/topic/117597-shopping-cart-design/#findComment-604898 Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 What I do is create a table that temporaily holds what the user is selecting such as carttemp. the fields in the table can be id, sess, quantity, price, item. id is the unique key for the table, sess will store the session id for each user while they are visiting the site so when they check out, the system(the shopping cart) will retreive purchasing items base on the sess value. So here is the flow I would do. On the product pages, make sure to check if a session has been started like this if(empty($sess)) { $sessID = session_start(); } Then, you will need to create a View My Cart page that will hold the current items picked. When they click the button to add to cart, this will direct them to the View My Cart. This is where you need to insert the items picked into the carttemp table During the checkout process, make sure to use the session id to retreive the items from the carttemp table. You can also create another table to store items that has been bought. That's the general idea. Hope this gets you started. AM Quote Link to comment https://forums.phpfreaks.com/topic/117597-shopping-cart-design/#findComment-604903 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.