SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Jun 1, 2005, 01:41 #1
- Join Date
- Jan 2005
- Location
- London
- Posts
- 186
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
adding size and colour options to products within a shopping cart
Hi There
I have just finished building my first shopping cart in asp and MS Access. Originally the shopping cart was to be built for products with no size and colour, however as usual the goal posts have moved and I now need to incorporate a size and colour option for each product. Could anyone explain to me how I can go about doing this i.e. adding the different sizes and colours in the admin website and then linking them to a specific product when it is displayed on the products page? I know they both need to be in a dynamic drop down box when displayed on the products page within the shopping cart, but I am just wondering how to read the correct values out from the table depending on which product is being displayed. I have a normal products table at the moment with general fields i.e ID, name, description etc.
Many thanks in advance for your help.
-
Jun 3, 2005, 05:48 #2
- Join Date
- Nov 2001
- Location
- RI, USA
- Posts
- 140
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It sounds like you need to add some more tables to your database...
1) If 'size' and 'color' will be the ONLY added options...
You can add two more fields to the Products table called 'sizes' and 'colors'. Then for each product store the available options for each in a comma separate list..
prod_id : 1234So when you display your product detail.. just parse the comma separate lists into an array. Then loop through the array to display your select list options...
name : tee-shirt
colors: blue,red,yellow
sizes: s,m,l
For example:2) If 'size' and 'color' will NOT be the ONLY options (oops we forgot about 'material','flavor','monogram location',etc..)... It would be best to create antoher table called 'ProdOptions' that shares a ProdID field with the products and then manage all of the potential options for each product in this table.
Code:' -- code to open product detail RS here -- ' create colors array a_colors = split(rs("colors")) ' start select tag response.write "<select name='colors'>" ' loop through the array to display options for i = 0 to uBound(a_colors) response.write "<option>" & a_colors(i) & "</option>" next ' end select tag response.write "</select>"
I also didn't mention how of all this gets managed in your shopping cart! Do you have a table for the cart?
Bookmarks