Prevent checkout of out of stock products?

Open to all! Ask other shopowners for help.
Post Reply
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Prevent checkout of out of stock products?

Post 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Prevent checkout of out of stock products?

Post 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.
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Prevent checkout of out of stock products?

Post 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.
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: Prevent checkout of out of stock products?

Post 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.
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: Prevent checkout of out of stock products?

Post 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.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Prevent checkout of out of stock products?

Post 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
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: Prevent checkout of out of stock products?

Post 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. :)
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Prevent checkout of out of stock products?

Post 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
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Prevent checkout of out of stock products?

Post 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply