Doug, here's what I've always done.

User visits site - CF creates a shopping cart key (createUUID()) and 
stores it in the session scope, as a cookie, or puts it into a very 
simple CARTS table.

My cart_contents table looks like this (pardon the caps, I still use 
caps for SQL)

CREATE TABLE CART_CONTENTS (
   CART_KEY char(35) NOT NULL default '',
   PRODUCT_ID int(10) unsigned NOT NULL default '0',
   OPTION_ID int(10) unsigned NOT NULL default '0',
   QUANTITY int(10) unsigned NOT NULL default '0',
   ACCESS_TIME datetime NOT NULL default '0000-00-00 00:00:00',
   PRIMARY KEY  (CART_KEY,PRODUCT_ID,OPTION_ID)
) TYPE=MyISAM;

This setup allows me to have multiple SIZES/COLORS of each product in 
the cart, and keep them separate.  The "access_time" field allows me to 
delete old cart contents.

When the user checks out, an ORDER is created in the ORDERS table, and 
the I *COPY* the cart_contents items into an ORDER_CONTENTS table with 
the same structure, except the order_contents table also contains the 
CURRENT price of the product.  Never rely on your products table for 
historical price information.  I had a customer that was constantly 
changing prices, and if I only did joins to the product table to get 
price, things would get ugly.  You could optionally maintain a 
"price_history" table or something, but that overcomplicates it if you 
ask me.

After checkout is complete, the cart_key stored in the session scope is 
deleted... if they do more shopping, an ew cart_key gets created.

Rick


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262568
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to