memooney Posted November 30, 2005 Posted November 30, 2005 I'm setting up an online purchase system for a cooking store. They offer classes for their customers. The classes have a limited size (e.g., 20 people max). In the past, the classes have sold out in a matter of hours. So here is my concern: Let's say Sally wants 2 seats in the Sushi class and 1 seat in the grilling class, and 1 seat in the pastry class. She adds the 2 seats in the Sushi class to her cart, then continues to the grilling class and adds 1 seat for that class to the cart, then on to the pastry class and adds a seat, then wants to check out. It's very likely that if I wait until she checks out to "reserve" those seats for her, someone else will have purchased them. So I need to "reserve" the seats when she adds them to her cart. That's no problem. My concern is, what do I do if she doesn't check out? These seats are pulled from the class, and are now unused. I've got ideas rolling around in my head, but I'm guessing some of you have already faced something like this, so I'm hoping you can save me some time and figuring it out. Basically, I'm adding a record to the DB that pulls the seat when she adds it to the cart. So what do you think the best way is to double check on a regular basis (every 15 minutes or so) that Sally has completed her transaction? Matthew Quote
TCH-Rob Posted November 30, 2005 Posted November 30, 2005 You could use sessions that have a timeout on them. That way, if nothing is done in a certain period of time the transaction should be negated and those items go back into the pool. Quote
memooney Posted December 1, 2005 Author Posted December 1, 2005 I guess I'm lost then. How can I control records in the DB with sessions? If the session times out on the user's computer, how does the record get updated in the DB? Quote
Deverill Posted December 1, 2005 Posted December 1, 2005 Hi Matthew, In a PC application I'd mark the seat "Tentatively reserved" when she clicks it and then "Permanently reserved" when she checks out. Then you could periodically go through and if they aren't still working (session still active?)on it you could "unreserve" the Tentative ones. Not too sure how to do this in a web environment - a timed script or session timeouts, etc - but it may get you going in the right direction. Hope it helps! Quote
memooney Posted December 3, 2005 Author Posted December 3, 2005 Thanks for the suggestions. I have an idea and from the "Server Side" of things I want your opinions. Originally, I was thinking of something along the lines of what Jim suggested. However, I was planning to have an automated way of doing things. So here is my thought. When Sally adds some seats to her cart, it "reserves" the seats in the DB and adds the epoch date. Then if she completes the checkout, it would update to purchased from "reserved." To address the poeple that don't check, I was thinking of using a CRON job to execute a script that would query the DB and look for any "reserved" that are more the 30 minutes old and release those seats. Historically, the classes sell out in about 2-3 hours. So I was planning to have teh CRON job run every 30 minutes on the day the registration opens. Then every 6 hours have that to catch any stragglers. Does that sound like a solution that will work? I haven't used CRON job before, but understand how they work. From the server side of this do you see any problems or concerns in running this CRON job as I've described? Thanks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.