dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: PHP shopping cart

  1. #1
    Join Date
    Nov 2007
    Posts
    67

    PHP shopping cart

    Hi guys,

    I'm trying to create a shopping cart. A product can have a few options such as size and color. I'm having trouble counting quantities from different mixes and matches. Let's say I have 10 small green shirts and 5 red large shirts.

    the product option value table would look like

    quantity:10, value:small
    quantity:10, value:green
    quantity:5, value:red
    quantity:5, value:large

    How can I combine it so that I know there are 10 small green shirts and 5 red large shirts?

    Here are my current tables.

    `product_option_description` (
    `product_option_id` int(11) NOT NULL AUTO_INCREMENT,
    `product_id` int(11) NOT NULL,
    `name` varchar(200) NOT NULL,
    PRIMARY KEY (`product_option_id`)

    `product_option_value` (
    `product_option_value_id` int(11) NOT NULL AUTO_INCREMENT,
    `product_option_id` int(11) NOT NULL,
    `product_id` int(11) NOT NULL,
    `value` varchar(200) NOT NULL,
    `quantity` int(11) NOT NULL,
    `price` float NOT NULL,
    PRIMARY KEY (`product_option_value_id`)
    )

    Thanks,
    Any help is appreciated.
    Last edited by Blizzard84; 09-29-2010 at 04:46 PM.

  2. #2
    Join Date
    May 2006
    Location
    the netherlands
    Posts
    454
    where do you have the problem? in the php-code or in your database query?

    i also have my doubts you set up the tables correctly

    IMO product_id should not be part of the values-table, since the option-id already implies the product id
    also, quantity should - IMO - not be a part of this. Quantity is part of the order that someone places, but it makes no sense to store 3x green under the 'colour' option of your shirt as something that people can choose.
    and price should be the price difference compared to the base-price which should be set on the product (but maybe that's how you use it already)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles