Reserve items in shopping cart
Question has been asked with no answers over a month ago: Shopping Cart reserve product
I have a shopping cart for my site in ASP.NET using SQL Server. When a user adds an item to the shopping car开发者_JAVA技巧t I need to set a value in the product table to reserve the item (in order to avoid more people reserving the item, or buying it). Now, if the current user decides to abandon their cart by closing the browser, then how am I to restore the product record to being 'unreserved'?
Is there another way of reserving the item globally?
When a user "reserves" an item give the reservation an end date/time (e.g. DateTime.Now + 6 hrs, or whatever), by which they must have purchased the reserved item, otherwise after that date/time the reservation becomes void - I believe this is how the vast majority of bricks-and-mortar shops would work as well.
If you're worried about having a tbReservations table with loads of deprecated rows you can setup a SQL job to clear the table of old/invalid reservations each night or whenever is suitable for the business case.
Read the post by Benson Yu in this thread. In the Session_End
method you can "unreserve" the products that were not checked out.
精彩评论