View Full Version : simple shopping cart
i am trying to build a simple shopping cart which allows a user to add products to a cart, view products in the cart, remove items and change quanties and pricing, i dont need it to do any payment solutions or anything like that.
i have all the products within a mysql database, and i have managed to display these in a web page with a simple category tree listing in one frame which populates product listings in the main frame depending on what category you have clicked on.
All the products have a buy button which holds a unique product_id.
any help would be great.
01-04-2007, 06:09 PM
Can we please see some code? We're here to help, not working hard making a whole code for you to profit my impressing someone.
As the above poster said, I don't want to get into writing a mountain of code for you. However, if you want a basic idea of how to go about solving the problem I'd say this:
You probably don't want to user selected items anywhere in your database permanently, as I imagine the shopping cart should empty when the shopper leaves the site. Therefore, one solution would be to store the product ID's of the selected products in session variables. Assuming that all product ID's are the same length, you could even store them back to back in a single session variable, and when the shopper goes to "view" the cart you could create substrings of that variable to grab each product ID and place it into it's own variable. Then, call a function that uses the product ID to retrieve and display information about the product, which will loop until all of the variables are exhausted. As for adding the amounts, at the end of the loop you could place a counter that increments by the value of the product each time one is displayed, so that in the end the value of that counter would be the purchase subtotal. You can calculate tax by multiplying that subtotal variable by .07 or whatever.
That's just some thoughts off of the top of my head. Please note that I've never developed a shopping cart before though so there may be a much better way to do this. **hurls a massive grain of kosher salt**
sorry guys i didnt really have any code for the shopping cart what so ever, however i managed to actually create a shopping cart, using snippets from the follwoing link.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.