Forum
Reserving product while checking out. Avoiding parallel buying and negative inve...
As far as I can tell from my testing cases, it is possible to have 1 item (last in stock) and for two people to buy it at the same time.
This ends up with the scenario that you have two successfully paid orders of an item you only had 1 in stock of.
Is there a way to avoid this problem inbuilt in the shop, or a possible way to work around it by manually marking the item as sold while someone has it in their cart etc.? Or another option; on the last step of making the payment; making sure the product hasn't been sold while you were checking out yourself? Not the greatest user experience of course, to go through the whole checkout, only to – after paying – get feedback that "Sorry, the item is sold out".
Any feedback would be greatly appreciated.
Eddie
We check stock levels when reconfirming the cart before checkout, but yes, you can have multiple customers at that stage before payment is processed.
The only way to deal with that is to put a timed lock on products like a ticket selling website would. That's not something that Shop does currently. If it's a feature you need then Shop might not be the right solution.
Fair enough. Thanks for the answer.
It is any way to reconfirm the stock level before the payment goes through?
Say to add some function to check the inventory one last time before charging.
Maybe by saving all the products in the order in an array and hitting the perch_shop_product() with each of the products – returning and saving the stock count of each in variables.
Will try that, but if there is any better way of checking the stock level of the items in the cart before proceeding with payment, advice is more than welcome.
I really want to be able to use Perch shop on this, but its very important to be certain that limited edition products don't risk getting sold more of than available.
perch_shop_cart()
will essentially do this, so you could always call that and null the output.That definitely returns the information I need, but it doesnt seem to update live.
If I add to cart, and go to the last step (with order-overview and payment options), and var_dump the perch_shop_cart, the returned stock_level is stuck at the value it was when it was initially added to the cart – even though I change the stock count in perch admin. It doesn't matter how many times I refresh, the stock_level is stuck.
The same applies to going to the cart.php page. It still shows the item in the cart, even though its actually out of stock. Only if I go back to the product and try to add it to the cart again it clears the cart.
Any idea on why the stock_level doesn't update when refreshing?
Returned array for info (long after i've changed the values of stock level to 0 in admin):
No, no idea. It certainly should update the stock values when displaying or updating the cart. Does updating the cart help?