SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Apr 1, 2005, 01:18 #1
- Join Date
- Jan 2005
- Location
- London
- Posts
- 186
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How to place shopping basket contents into Orders Table
Hi There
I am reaching the point in the implementation of my first shopping cart where I need to place all the customer’s products within their shopping basket into an orders table. I am sure many of you have performed this task before so I wondered if you wouldn’t mind pointing me in the right direction. I am not really sure exactly what is usually stored within the orders table in most shopping carts. My shopping cart contents is stored in a session array like this
IF NOT isArray( Session( "cart" ) ) THEN
DIM localCart( 5, 20 )
ELSE
localCart = Session( "cart" )
END IF
FOR x = 0 TO UBOUND( localCart, 2 )
IF localCart( CARTPID, x ) <> "" THEN
orderTotal = orderTotal + ( localCart( CARTPPRICE, x ) * localCart( CARTPQUANTITY, x ) )
nWeight = nWeight + ( localCart( CARTPWEIGHT, x ) * localCart( CARTPQUANTITY, x ) )
DIM chId,chProduct,chPrice,chQuantity, subtotal,ChWeight
chId=(localCart( CARTPID, x) )
chProduct=Server.HTMLEncode( localCart( CARTPNAME, x ) )
chPrice=formatCurrency( localCart( CARTPPRICE, x ) )
chQuantity=localCart( CARTPQUANTITY, x )
ChWeight=localCart( CARTPWEIGHT, x )
subtotal = chQuantity * chPrice
Now I presume that once the merchant bank has verified the customer’s credit card I need to place the contents of the cart into an orders table. Is it normal for the Orders table to have a structure like the following? If yes then I need some help getting all the session contents into this table.
OrderID
ProductID
ProductCode
ProductName
ProductWeight
ProductCost
Quantity
SubTotal
Date
If my idea of how it all works is not the normal way could someone please let me know how it is usually done as this is my first implementation of a shopping cart.
Finally how and at what point do I create an order number, which references a particular order by a customer?
Many thanks in advance.
-
Apr 1, 2005, 11:34 #2
- Join Date
- Oct 2000
- Location
- Philadelphia, PA
- Posts
- 4,708
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
I would have a table for your orders, and a table for your ordered products.
What if the customer orders two different items? You should enter one distinct order record in your order table, and the multiple ordered products record in the ordered products table. The quantity, price etc should all go in the second table as well."Does this napkin smell like chloroform?"
...now with SnapFoo!
My Blog | My Twitter | My Company | SitePoint Podcast
*** Matt Mullenweg on the SitePoint Podcast ***
-
Apr 2, 2005, 05:28 #3
- Join Date
- Jan 2005
- Location
- London
- Posts
- 186
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How to perform the actual task using the 2 table method.
I think I understand!
So from the code that I have posted up how would I then go about performing the actaul inserting the correct data into the 2 tables as you suggested. Would I first create a record in the orders table, which would then reference products within the orderedItems table? If yes how would I go about doing that?
many thanks in advance
Bookmarks