-
Stock control
Hi everyone,
Just after some advice before I start coding on stock control.
We have a product table that has a stocklevel field... I'm just after some advice on how to stop a product being sold if two people add it to their cart and purchase it at the same time.
At the moment, they add the item to the cart and click checkout. Then a credit card screen pops up where they purchase the order. I'm thinking at that stage I would pass back whether the credit card was accepted, send the order and minus the ordered stock amount from the product stock level... however this would not stop two people clicking checkout at the same time.
Is there a standard way for doing this?
Please let me know if you want to know my tables layout. Its quite simple, a product table, customer, order and order item table...
Thanks for your sugguestions :)
-
Re: Stock control
I don't know if there is a standard way of doing this. But whoever pays first should get it, I guess. The other person would then have an order of a product that would be back ordered, and then they could cancel the order or do whatever. So, I would take away from the product stock number when the item is paid for, I guess, and when they're just about to finish paying with their credit card, you can check again if the item is there or back ordered.
Or, you could try locking your tables whenever someone is adding an item to the cart, and then unlock them as soon as you have finished updating the stock value. Or something like that?
-
Re: Stock control
Thanks kows.
We are going to add a third party credit card payment system, so will see what variables I can pass through back to our site. I assume I will be able to pass back as many as required.
But as soon as they hit checkout it opens the one payment page where they enter their details. So there isn't really a place where we can double check the stock and give it to the first person that pays.
Once we have the credit card system in place I'm sure I'll be able to see what we can and can't do. Hopefully the likely hood of two people ording the same last item is relatively low... will come back here if I can see something achievable.