Shopping Cart reserve product

2019-08-07 12:31发布

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

标签: paypal
3条回答
Anthone
2楼-- · 2019-08-07 12:40

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...

查看更多
甜甜的少女心
3楼-- · 2019-08-07 12:48

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.

查看更多
Viruses.
4楼-- · 2019-08-07 12:57

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).

查看更多
登录 后发表回答