views:

90

answers:

2

Hey everyone,

Question has been asked with no answers over a month ago: http://stackoverflow.com/questions/1806739/shopping-cart-reserve-product/2070884#2070884

Anyway, basically I have a shopping cart for my site in ASP.NET using SQL Server. When a user adds an item to the shopping cart 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 abondon 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?

Many thanks

+1  A: 

Read the post by Benson Yu in this thread. In the Session_End method you can "unreserve" the products that were not checked out.

klausbyskov
It's working with session InProc mode, only!!!
dario-g
+2  A: 

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.

Robert W
+1. Session_End() isn't reliable.
RickNZ