Prevent Checkout of Products with Out of Stock Status in Saved Carts

Open to all! Ask other shopowners for help.
Post Reply
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Prevent Checkout of Products with Out of Stock Status in Saved Carts

Post by heatherbell »

Prevent Checkout of Products with Out of Stock Status in Saved Carts
--------------------------------------------------------------------

Customers can save a product in their cart and checkout at a later date when the product has since had its status changed to Out of Stock.
This hook prevents that by removing products with a status of Out of Stock from the customer's cart when they checkout and displays a message to say so.
Tested on Phoenix v1.0.7.9

Installation
------------

Upload all other than this README file.
There are ZERO over-written files so you are sure to be safe to upload all.

Credits
-------

Thanks to @ecartz for the solution and code.
You do not have the required permissions to view the files attached to this post.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Prevent Checkout of Products with Out of Stock Status in Saved Carts

Post by burt »

I'm wondering if this is needed in 1.0.8.21 ?

I can't get to the checkout in 1.0.8.21 (haven't tested in anything older) when;

Mickey Mouse adds Green Tomato to cart. Doesn't matter if he logs out or stays logged in.
Admin sets Green Tomato product status = 0 (ie deactivated).

On the next page load, Mickey Mouse gets a message saying;

"Green Tomato has been removed from Cart".
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 Products with Out of Stock Status in Saved Carts

Post by heatherbell »

burt wrote: Mon Nov 20, 2023 11:40 am I'm wondering if this is needed in 1.0.8.21 ?

I can't get to the checkout in 1.0.8.21 (haven't tested in anything older) when;

Mickey Mouse adds Green Tomato to cart. Doesn't matter if he logs out or stays logged in.
Admin sets Green Tomato product status = 0 (ie deactivated).

On the next page load, Mickey Mouse gets a message saying;

"Green Tomato has been removed from Cart".
Tested on latest 1.0.8.21 and see the same as you.
Only exceptions seen are when customer is in the middle of checkout process when the product is deactivated e.g. on checkout_shipping.
Then the message stack does not appear but the product is removed.
If the customer is on checkout_confirmation when the product is deactivated, then clicks Finalise, the order is processed but product is removed from order.
These exceptions are only observations, that is, not saying they are "bugs" or require a "fix".
Conclusion that it now seems impossible to order a de-activated product.


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