tags:

views:

70

answers:

4

Following on from this question here, how does one reserve a product in a shopping cart when a user goes to pay? What if the user abandons the purchase and does not come back to your site, how will you unreserve the product if the page is not being reloaded. For that matter how would you reserve the product in the first place? I am creating a cart using php mysql and using paypal web payments standard. Thanks

A: 

I too need this answer, with asp.net and MS Sql. Problem being, you need to flag the SQL record in order to avoid others reserving the item at the same time, but if the first user closes the browser there is no way to unreserve the item in sql...

David
set another time, lastReserveTime, compare to your current time, if the timespan > http session timeout, user has left, this product can then be reserved by others
Dapeng
What a guy. nice one!
David
A: 

You can create a cron job that will run periodically and check if there are any reserved items that have not been paid for in time (for example, within 24 hours from reservation).

Kniganapolke
A: 

A clean solution that works well for us is to use an "internal order" type system. The product table would hold the product details as well as the stock on hand. When a user reserves the product we treat it as an internal order, so in an order table you'll have the item that the user has reserved and the date and time that it was reserved. You can then decrease the stock quantity in your product table based on the number of units the user has reserver.

Then you can on the nightly basis for example check for internal orders that have not been converted to invoices and subsequently remove them from the database increasing the stock quantity in your product table based on the number of units that were reserved but not invoiced.

If a use however ends up completing the purchase the item is simply converted to an invoice. We use the same table for both invoices and orders in some instances with a simple field that specifies whether the record is an invoice or simply an internal order.

garyj
A: 

i think this is in fact the best answer: http://stackoverflow.com/questions/1357143/shopping-cart-and-stock-management

David