Hi all, this is actually more a wordpress/woocommerce issue I guess, but it is harder for me to get a helpful response in their proper channels, so I am asking here in desperation.
I have this issue with a big store of a client that is bugging me for months now, hence I migrated from EE3 to WordOps initially, but the issue persisted.
I have been digging through the logs and I managed now to pinpoint what I THINK is the problem:
In very large orders with dozens of different products the checkout processing can be slow sometimes (around 10s to finish the response as I can see in the access.log file) problem is that the payment gateway when the credit is ok responds right away the order and I am guessing the first is still processing and reducing the stock of the products AND the response from the gateway comes in and wordpress starts reducing the stock again while the first is still in processing on the server.
Sometimes it is a partial stock reduction, like lets say the order contains 50 products and it reduces for a second time only half of them, but most of times it reduces twice.
The fact that it only happens on relatively large orders got me thinking it is the timing that is the issue.
The way I see I could do 2 thing for now:
1) try to delay ANY response from the payment gateway for at least 15s, lets say... but I do not know if this is possible in nginx... (it would be something like 'if checkout has been requested delay ANY payment gateway communication for 15s')
2) Find a way to tweak wordpress/woocommerce functions to flag an order as 'being processed' and not accept (or delay) any other request regarding that order untill the first one is done and the flag is removed. But again, I am not sure this is possible.
So, any insights would be helpful. Thanks in advance
P.S.: I was thinking also as a makeshift temporary solution to increase server resources, but it is already expensive for my client ATM and he prolly won't allow me