Hi everyone
I'm sure there are many open source Ecommerce scripts out there but because of some reasons i'm building my own.
I'm having a problem with reserving products.
Here's what I need :
when the administrator of this webshop adds a new product he also need to choose the quantity of that product available in stock which is not so hard to do with PHP and MySQL. Each time a customer purchases a product the script will decrease the quantity in database and when all of them are purchased then the product will no longer be available on the website. But the problem occurs when several customers buy the same product at the same time.
Lets say there's a product with the quantity = 1 . what happens when 2 customers buy it at the same time? I mean there should be a way to reserve that product when ever a user adds it to his shopping cart.
I could come up with some ways to do this job, Like decreasing the quantity when a user adds that product to his shoping cart and increasing it when he cancels the payment. But these ways generate a high trafik to MySQL and this way might not be so safe. because if the user closes the browser without canceling the payment then the quantity will not be increased.
Any idea will be appreciated
Thanks