Page 1 of 1

Prevent checkout of out of stock products?

Posted: Wed Aug 18, 2021 3:07 am
by lecarlb
Phoenix version: 1.0.8.4

I have seen 2 instances today where customers were allowed to purchase out of stock products. When I looked at the stock levels there were minus amounts or less than zero.

I have allow check set to false and I have the out of stock notice module in place. What else should I check?

Thanks.

Re: Prevent checkout of out of stock products?

Posted: Wed Aug 18, 2021 6:07 am
by ecartz
Did you have two orders simultaneously where one is some kind of hosted checkout (e.g. PayPal)?

It doesn't reserve the stock until payment is completed. So it is possible to sell an item, redirect to PayPal (or whomever), sell another item, deduct stock for the second item, deduct stock for the first item. Because it already thinks that it sold the first item, it doesn't check stock levels again.

Re: Prevent checkout of out of stock products?

Posted: Wed Aug 18, 2021 7:56 am
by 14Steve14
I kept having similar problems where customers would buy something that was out of stock. I think these orders were coming from people that had added the items into their carts, not paid on the day, but did complete the order at a later date. This was happening on 1.7.10.

I cant remember what we did to stop this happening as the thread is on another forum, but I think it entailed adding a further check on the stock before allowing checkout to happen, but like I say I cant remember exactly what.

Re: Prevent checkout of out of stock products?

Posted: Wed Aug 18, 2021 10:30 am
by lecarlb
ecartz wrote: Wed Aug 18, 2021 6:07 am Did you have two orders simultaneously where one is some kind of hosted checkout (e.g. PayPal)?

It doesn't reserve the stock until payment is completed. So it is possible to sell an item, redirect to PayPal (or whomever), sell another item, deduct stock for the second item, deduct stock for the first item. Because it already thinks that it sold the first item, it doesn't check stock levels again.
I use stripe where checkout is seamless. That scenario could still be true.

Re: Prevent checkout of out of stock products?

Posted: Wed Aug 18, 2021 10:33 am
by lecarlb
14Steve14 wrote: Wed Aug 18, 2021 7:56 am I kept having similar problems where customers would buy something that was out of stock. I think these orders were coming from people that had added the items into their carts, not paid on the day, but did complete the order at a later date. This was happening on 1.7.10.

I cant remember what we did to stop this happening as the thread is on another forum, but I think it entailed adding a further check on the stock before allowing checkout to happen, but like I say I cant remember exactly what.
The scenario you described could be true. Maybe emptying carts after a set period would help. I may explore the other forum later. Thanks.

Re: Prevent checkout of out of stock products?

Posted: Wed Aug 18, 2021 10:50 am
by heatherbell
lecarlb wrote: Wed Aug 18, 2021 10:33 amI may explore the other forum later. Thanks.
It's here - viewtopic.php?f=28&t=163

Re: Prevent checkout of out of stock products?

Posted: Wed Aug 18, 2021 12:44 pm
by lecarlb
heatherbell wrote: Wed Aug 18, 2021 10:50 am
lecarlb wrote: Wed Aug 18, 2021 10:33 amI may explore the other forum later. Thanks.
It's here - viewtopic.php?f=28&t=163
Thank you @heatherbell. I guess I used the wrong keywords when searching late at night. I installed the fix with the code change to fix the one error mentioned. :)

Re: Prevent checkout of out of stock products?

Posted: Thu Aug 19, 2021 6:48 am
by heatherbell
lecarlb wrote: Wed Aug 18, 2021 12:44 pmI installed the fix
Note that the hook removes products where products are marked Out of Stock so in your specific use case, ensure products are marked Out of Stock if stock<=0

Re: Prevent checkout of out of stock products?

Posted: Thu Aug 19, 2021 8:30 am
by 14Steve14
Glad @heatherbell could remember that. I looked through my notes and could not find a mention of anything. After I installed it, it seems to have stopped most of the problems I was having.