[thelist] Shopping Carts -- where to store price

Warden, Matt mwarden at odyssey-design.com
Sat Sep 9 18:41:43 CDT 2000


In recent projects where I'm building a shopping cart system from scratch,
I've always decided to store the product foreign key as well as the product
price in the cart table. Even though price is also in the product table. I
did this to avoid a certain situation. Let's say Bob Shopper has just put 12
widgets in his basket at $1.42 a pop. Immediately afterwards, Mr. Ecommerce
Site Admin ups the price on Widgets to $2.00. Then, Bob clicks "checkout"
and his total has jumped from [Windows Button + R... "calc"] $17.04 to
$24.00. He has no idea why. Hidden charges? Scam? Evil cookies?

Lost customer? Possibly. So, I've always stored the snapshot of the product
price in the basket table (as long as the basket doesn't persist beyond a
browser session). Does anyone else do this? I figure that the worst case is
that Bob can buy 600,000 widgets at the old price when it was just bumped up
ten seconds ago. Certainly that's better than losing Bob forever because he
doesn't trust the voodoo that's going on behind the scenes, eh?


More information about the thelist mailing list