Forums / General Questions / Same product sold twice

Same product sold twice

Locked

Started by fetsy on 27 Jul 2008, 7:47 AM · Views: 1,194

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
27 Jul 2008, 7:47 AM
#1
fetsy avatar

fetsy

New Zenner

Join Date:
Mar 2008
Posts:
4
Plugin Contributions:
0

Same product sold twice

We will soon introduce some products to our store that most likely will be sold within minutes after they have been put for sale. In order to check how Zen-Cart behaved when more people try to buy the same product, we simulated a situation where two customers put the same product in the shopping-cart and completed the check-out more or less simultaneous. The result was that both orders went through and the stock went to -1. The stock settings are set to not allow checkout when products are sold out.

Does anyone have a suggestion to what we can do to avoid selling the same product many times?

Now we tried this with the bankdeposit module. Anyone having an idea if the same will happen using paypal (as the only choice)?

27 Jul 2008, 8:04 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Same product sold twice

Stock is reduced upon completion of a successful order - changing this is much code to alter

Zen-Venom Get Bitten

6 May 2009, 10:50 AM
#3
jetblackstar avatar

jetblackstar

New Zenner

Join Date:
May 2009
Posts:
1
Plugin Contributions:
0

Re: Same product sold twice

Since we've encountered the same problem I thought I would add my tuppence. (More like £20 note, but hey)
Yes, it does happen with Paypal and by Cheque. As far as I can see it will happen with any payment module if two customers get past the "Confirm Order" page before one of them is returned from the payment module.

Kobra (presumably an aficionado :wink: ) is dead right the stock decrement is done after the payment module. Checks are done for stock at the latest on the loading of the Confirm order page. It is also very heavily entwined by the looks of it into the final processes. The names baffled me for some time but order->create_add_products (In orders.php class code) seems to be responsible for re adjusting stock levels. It appears to be called from within checkout_process.php, which I thought was just before the payment module. Of course I could be completely wrong, and have missed the proper final program. But I'll shove that up for anyone desperate in the future.

The design is based on a "When you've paid me, I record the stock decrease" concept. Which, in high stock levels doesn't matter too much if you over sell 1, as you will likely be able to restock and apologies and inform the customer (If you notice). However as many unique item sellers are finding (Crafts, antiques, second hand books, etc), this is not an appropriate design weakness for them. Especially those whom do bulk updates and have a Hawking customer base. Its not about Zen cart being wrong, its about a different shop business model.

Decrementing the stock when It is put in the cart is also fairly incorrect, as often carts are abandoned, Disconnected, or intentionally left full and floating. Meaning that customer is withholding stock from other customers by hiding in the toilet with a full shopping basket. It is closer to the real life metaphor though. And it will seem an appealing solution to those with this problem. Code could be written to compensate, but it isnt in Zen as its not designed like that.

A middle ground would be to reserve any items in a basket until there abandoned etc, perhaps putting them in a reserved stock figure. Then waiting until the payment is processed to properly decrement the stock. This however is a completely different model and not easy for Zen to bend itself to.

Still, long and short of it is Zen does not work like this. If you are reading this in search of a solution, as far as we have found your options are;

  1. Mildly modify Zen to add another stock check in the Checkout_process to further decrease the window where two people can purchase the last stock item.
  2. Try and hack the stock change as it stands to be placed in the beginning of the checkout process (checkout_shipping). An advisable alternative to doing the stock decrement on entry into the basket. This will be difficult and potential dangerous to other safety checks in Zen-Cart.
  3. Put up with it and prepare your eager customers to get refunds.
  4. Wait until Zen-Cart 2.0 which may address this issue.
  5. Find another product