Click to See Complete Forum and Search --> : Programming a shopping cart
aaron123
08-06-2008, 04:19 AM
I am almost done developing this e-commerce site and my client just asked me to add a shopping cart. I have some templates, but I want to start from scratch, is there a specific way of starting to do it? What should I consider when building a shopping cart?
If you can find a code library that would be best. Programming a shopping cart is a large task from nothing. Don't get me wrong, it can be done but sometimes its better to resist rebuilding the wheel.
The best way to accomplish this would probably be creating a cookie manager and just pushing in the item ids. I'm not sure how the back end is setup but normally products are pulled from a database and they have a unique id. You could also use a session rather than a cookie to accomplish the same thing.
$_SESSION['cart'] = array();
$_SESSION['cart'][] = 58;
$_SESSION['cart'][] = 45;
$_SESSION['cart'][] = 65;
Than you would just iterate through the $_SESSION['cart'] array and grab all the products from the database to show a visual representation of what has been ordered.