Jump to content

Shopping Cart Design


millercj

Recommended Posts

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?

 

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.