Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm doing my first ecommerce site and have a quick question RE: updating inventory: once someone starts the purchasing process I want to make sure that the item is reserved for him until the transaction is completed. I can think of several easy ways to do this. What I can't quite figure out is what to do if the user adds the item to his cart and then leaves the site before completing his purchase. How do I know to add the item back to inventory?

Thanks!

--TWH

Replies are listed 'Best First'.
Re: Transcation based sales...
by Joost (Canon) on Jul 19, 2004 at 22:08 UTC
    You can add a time-out. I'd probably use the session timeouts for that, ie. if a session is timed-out and cleared removed, put the items in it "back in the main storage". Session time-out usually happens about 15 - 30 mins after the last request made using that session.

    This doesn't protect you from potentially (and temporarily) reserving too many items. You could "run out" of stock without actually selling everything, but it's a friendlier way of handling potential customers.