Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Need to come up with a way to "temp hold" inventory and give user only a certain time to complete a transaction, like 5 minutes;
Problem is 2 people booking same inventory at the same time. How can we make sure this does not happen?
a). Can we "temp hold" the inventory for the first user and if they do not book within 5 minutes, release the hold or something simiilar?

please help me
Posted

1 solution

I have implemented it the following way long time ago. See if it works for you.
Flow
1. Customer visits product catalog page.
2. Customer selects one or more items and adds them to the shopping cart.
3. Each time an item is added to the cart,
A stored proc is invoked to reduce the quantity of that item by 1 in the Inventory table.
The shopping cart for this user is kept in 'Awaiting Payment' Status in ShoppingCart Table.
4. Customer makes payment. Cart goes to 'Payment Completed' Status.
OR
Customer doesn't make payment and leaves. Cart stays in 'Awaiting Payment' Status for 2 hrs(configurable).
5. Every 5 minutes
a 'BookingCleanup' stored procedure runs (via a SQL job)
that goes to ShoppingCart table
converts all Carts in 'Awaiting Payment' status for more than 2hrs to 'Cancelled'
increases quantity by 1 in the Inventory table for each item in the cart
6. Meanwhile in these 5 minutes some more customers may have viewed this item and would have seen an 'Out Of Stock' message on the site. Those customer IDs are captured and emails are sent out by another scheduled job to tell them that the product is now back in stock.

[Please encourage participation by up-voting solutions or answers that work for you]
 
Share this answer
 
Comments
thatraja 4-Feb-14 1:57am    
5!
CoderPanda 4-Feb-14 4:52am    
Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900