Post by Limon12 » Fri Feb 12, 2021 7:39 am

Hello,

I have issue with OpenCart and I cloudnt find solution for it

Description

When two customers check out concurrently for the same product and the total quantity being ordered is greater than the quantity available, the stock can become negative even if the ‘Store Checkout’ setting under Stock is set to ‘no’.

Start site, create two customers, create/pick test product and allocate some stock.

Both customers add the product to their carts such that each cart individually is under the available stock, but combined they exceed the available stock.

Perform a checkout concurrently, making sure both customers finish checkout (click the ‘Confirm Order’ button) as close to the same time as possible.

We have reproduced this behavior on a single machine, by performing the above steps by simulating one customer in one browser window and another customer in a second browser window.

Expected Result

One of the two checkouts fails to complete.

Actual Result

Both checkouts succeed and the quantity for the product is negative in the admin console.
Last edited by Limon12 on Sat Feb 13, 2021 6:21 pm, edited 1 time in total.

Newbie

Posts

Joined
Sun Jan 10, 2021 7:05 am

Post by mikeinterserv » Fri Feb 12, 2021 7:51 am

While a theoretical test like this can and does seem to produce this result for you, in a more realistic scenario you are rarely if ever going to get customers checking out concurrently, even if you have many orders a day. The general time between real world checkouts will be enough for the problem to never occur and if it does it would be once in a blue moon. It is still a legitimate issue to raise though none the less. If it is a time issue its less of a problem than if its not time related but session or other related meaning a checkout like that may take place with a larger time frame in between. Did you try 5. 10 seconds apart etc
Last edited by mikeinterserv on Fri Feb 12, 2021 7:54 am, edited 1 time in total.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by by mona » Fri Feb 12, 2021 7:52 am

Amazon have the same problem :)

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by mikeinterserv » Fri Feb 12, 2021 8:03 am

Is it possible you have options set to NOT subtract stock
thinking about it I guess not or you wouldn't have negative stock :-)
Last edited by mikeinterserv on Fri Feb 12, 2021 8:17 am, edited 1 time in total.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by by mona » Fri Feb 12, 2021 8:12 am

The best way to handle it is to utilise the order statuses in settings.
You can then notify the customer of the order when you have had time to check there is stock.

You can adapt the language success page accordingly.
It is the standard way this is managed - there is also a delay in the payment process - there is no way to control that.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by straightlight » Fri Feb 12, 2021 11:12 am

Limon12 wrote:
Fri Feb 12, 2021 7:39 am
Hello,

I have issue with OpenCart and I cloudnt find solution for it

Description

When two customers check out concurrently for the same product and the total quantity being ordered is greater than the quantity available, the stock can become negative even if the ‘Store Checkout’ setting under Stock is set to ‘no’.

Steps to reproduce

Start site, create two customers, create/pick test product and allocate some stock.

Both customers add the product to their carts such that each cart individually is under the available stock, but combined they exceed the available stock.

Perform a checkout concurrently, making sure both customers finish checkout (click the ‘Confirm Order’ button) as close to the same time as possible.

We have reproduced this behavior on a single machine, by performing the above steps by simulating one customer in one browser window and another customer in a second browser window.

Expected Result

One of the two checkouts fails to complete.

Actual Result

Both checkouts succeed and the quantity for the product is negative in the admin console.
That's also because the order ID keeps getting generated as opposed to be validated (not a negative view, however) which will simply keep decrementing the stock value during checkout when the stock levels are not managed from the OC admin catalog products page.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Fri Feb 12, 2021 7:29 pm

by mona wrote:
Fri Feb 12, 2021 7:52 am
Amazon have the same problem :)
Yeah, it's a hard one to solve.

If it's a real problem you may be able to find an extension that lowers the stock level when someone adds a product to their cart.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by straightlight » Fri Feb 12, 2021 7:35 pm

paulfeakins wrote:
Fri Feb 12, 2021 7:29 pm
by mona wrote:
Fri Feb 12, 2021 7:52 am
Amazon have the same problem :)
Yeah, it's a hard one to solve.

If it's a real problem you may be able to find an extension that lowers the stock level when someone adds a product to their cart.
The stock levels are usually handled upon sales, not before the sale has been made from the store.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Mon Feb 15, 2021 6:52 pm

straightlight wrote:
Fri Feb 12, 2021 7:35 pm
The stock levels are usually handled upon sales, not before the sale has been made from the store.
Correct, and that's the problem.

There are pros and cons to doing it either way.

If you reduce stock when someone adds to their cart then you risk that they are a competitor adding all your products to stop you making any sales.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by mikeinterserv » Mon Feb 15, 2021 9:09 pm

You check the stock on confirm order
Like when the order completes it reduces stock by amount in cart
You check the stock level first before the order completes
That way if someone checked out even half a second before, the stock level will be reduced .
The order can then be returned to the cart with the message sold out or whatever.
There are probably 2 or 3 ways to prevent negative stock
In many years we never really had this problem and the only time it came up we checked stock on confirm order.
You can also prevent negative numbers in the DB and the DB itself can reject the order that takes stock negative.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by straightlight » Mon Feb 15, 2021 9:43 pm

paulfeakins wrote:
Mon Feb 15, 2021 6:52 pm
straightlight wrote:
Fri Feb 12, 2021 7:35 pm
The stock levels are usually handled upon sales, not before the sale has been made from the store.
Correct, and that's the problem.

There are pros and cons to doing it either way.

If you reduce stock when someone adds to their cart then you risk that they are a competitor adding all your products to stop you making any sales.
It doesn't stop you on making any sales. You simply have to remain in the competition when that happens as long as the maximum declaration rate limit has not been reached in the POS, the sales are still opened to the clients.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: thekrotek and 21 guests