Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts

    simple shopping cart

    Guys,

    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.

    cheers.

  • #2
    New Coder
    Join Date
    Oct 2006
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.



    Cheers,
    Shaffer.

  • #3
    New Coder
    Join Date
    Apr 2006
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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**

  • #4
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    http://www.thewatchmakerproject.com/...-shopping-cart


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •