Describe the bug
Follow steps below.
Details of the scenario :
To Reproduce
Steps to reproduce the behavior:
2
Aaaaand... we have an order with 2 units of the product which was available with only 1 unit in stock.
We need additional checks just before submitting order to avoid negative quantities and many logistic problems.
Additionnal information
PrestaShop version: 1.7.0.0 to 1.7.5.0
PHP version: N/A
Hi @kpodemski,
Thanks for your report.
I manage to reproduce the issue with the last version 1.7.4.2 / branch 1.7.5.x.
This PR: #8752 do not check the quantity of products available in the last step.
@marionf what do you think?
Best regards, Khouloud
Hello @kpodemski
Yes, we are aware of this and we talked about it with @alegout & @rGaillard when we added stock verification at each step but unfortunately for some technical reasons, we can't add this verification at the last step
@rGaillard if you want specify the technical reasons
@rGaillard explained me this :
In any case, there will always be a step where you will not be able to check the stock, for example on the payment provider's page
Adding an ajax check at the click of the button may slow down the process for the merchant's customer
@marionf
i agree, but... maybe it would be a good idea to give merchants a choice, at this moment it is considered as bug by many people and unfortunately causing a lot of issues
➤ marionf commented:
Hello @kpodemski
Yes, we are aware of this and we talked about it with @alegout & @rGaillard when we added stock verification at each step but unfortunately for some technical reasons, we can't add this verification at the last step
@rGaillard if you want specify the technical reasons
hey @rGaillard could you tell me more about those technical issues?
@PrestaShop/prestashop-contributors what do you guys think ?
At this step your customer can be on your payment gateway payment page, how do you handle this case? You just refuse the return of your payment gateway with no link between your shop and your payment gateway? This is a bad idea...
Hmmm, you won't be on payment gateway before clicking "Payment with an obligation to pay", right? We're talking about 1.7 only of course, the only issue i see could be with PayPal Express module and modules which skips this step...
Here is a solution that Axome gave us :
@eternoendless @PrestaShop/prestashop-core-developers @kpodemski @rGaillard what do you think of this solution ?
Apparently this bug was already present in 1.6. Can someone confirm ?
yes 1,6,1,24 have this bug too any fix_
ping @PrestaShop/prestashop-core-developers
I'll be happy to discuss this solution with you!
Here is a solution that Axome gave us :
- when customers reach the payment step, re-check stocks again (already done on the classic theme)
- when customers proceed to the payment, bank modules should be in "authorization" mode only : this allows to validate if the purchase is possible or not (the customer has virtually proceeded to the payment on the bank or payment platform).
- When returning to PrestaShop (PaymentModule::validateOrder method), there should then be a check on the stock and proceed to the order capture and creation ONLY if the stock allows it.
- If the stock does not allow it, the customer is redirected to his cart with an error message "this product is no longer available".
Our issue in closer look. We use ASM
Customer make cart and put items in them in one day, but doesnt process cart, not order. Next day some items comes 0 and system not allow to put them in new cart. So the safety order 0 products is OK. After that the customer come back to own cart from day ago and order without any trouble. The 0 items are ordered and we see -1 pcs on those items.
As far as i remeber this bug we meet much earlier then in 1.6.1.24. We use custom template, can be this issue of the template or core system?
I'm suffering this issue last days... Last Friday, I've reached -10 in a product stock because of this issue. So 10 customers that are dissapointed... 10 we are so sorry emails... 10 refunds.
What would be the best approach to solve this? I'm not talking about a technical solution.
What would be, in theory, the best solution?
This answer from Tobi (Shopify) from 2007:
One example of something we do behind the scenes is that items are “reserved” when a customer moves to the payment step. For 5 minutes the products in his/her cart are reserved for the buyer. This accommodates people who have to go hunting their house for their credit card whenever they want to buy online :)
Here is a solution that Axome gave us :
- when customers reach the payment step, re-check stocks again (already done on the classic theme)
- when customers proceed to the payment, bank modules should be in "authorization" mode only : this allows to validate if the purchase is possible or not (the customer has virtually proceeded to the payment on the bank or payment platform).
- When returning to PrestaShop (PaymentModule::validateOrder method), there should then be a check on the stock and proceed to the order capture and creation ONLY if the stock allows it.
- If the stock does not allow it, the customer is redirected to his cart with an error message "this product is no longer available".
@eternoendless @PrestaShop/prestashop-core-developers @kpodemski @rGaillard what do you think of this solution ?
Apparently this bug was already present in 1.6. Can someone confirm ?
@colinegin when you say that Axome gave you that solution... Do you mean a working solution? Is already implemented in your site? If yes, I'm very interested, and I would like to talk with them.
This bug is a very serious headache for me... I'm having a lot of orders with negative stock.
Hi @anfuca
Unfortunately, this is not a working solution, but rather a proof of concept. We had to think of a solution for this problem for one of our customers, and we ended up with this idea.
It still needs to be reviewed by prestashop core team because it has a lot of implications:
This being said, if you only use direct payment modules (card or paypal) that can be configured in "authorization only" mode, to have a working solution you would need to:
Would like to follow and support the idea of "holding" the 5 minutes reserved stock while processing the payment, and check the stock right before the payment step.
Another idea is to force payments addons to send a stock check and throw a payment error if the stock is not available anymore, would help with this concurrency issue a lot.
We developped a module with this in mind plus some "real time" capabilities that can be disable for avoiding high server workload :
https://addons.prestashop.com/en/stock-supplier-management/21707-temporary-product-reservation-lonely-stock.html
It creates a separate database and mostly rely on updateQty hook.
Module is sold since more than 3 years now, fully functionnal and debugged. Feel free to ask questions about this if needed, you can also take a look at our FAQ here : https://www.malttt.com/faq-products/?lang=en
@MattLoyeD your module is a nice workaround, and we used it for one of our projects :smile:
We had severe performance issues that we managed to fix in the module (database indexes, externalized CRON task, etc.), I would be happy to share these optimizations with you :wink:
@nsorosac So so true. That module has a very bad and serious perfomance problems. I would like to know those optimizations!
well the check of stock in the last step seems someone have found a way to do it: https://addons.prestashop.com/it/gestione-scorte-fornitori/48536-checking-stock-at-checkout-before-paying.html#specifications
why not implementing on Prestashop Core too?
We developped a module with this in mind plus some "real time" capabilities that can be disable for avoiding high server workload :
https://addons.prestashop.com/en/stock-supplier-management/21707-temporary-product-reservation-lonely-stock.htmlIt creates a separate database and mostly rely on updateQty hook.
Module is sold since more than 3 years now, fully functionnal and debugged. Feel free to ask questions about this if needed, you can also take a look at our FAQ here : https://www.malttt.com/faq-products/?lang=en
your module is nice but it remove all abandoned cart, and remarketing on abandone cart is a big money recovering.
Most helpful comment
Here is a solution that Axome gave us :
@eternoendless @PrestaShop/prestashop-core-developers @kpodemski @rGaillard what do you think of this solution ?
Apparently this bug was already present in 1.6. Can someone confirm ?