cancel
Showing results for 
Search instead for 
Did you mean: 

M2 Change stock status to out-of-stock when qty is less than 'Minimum Qty Allowed in Shopping Cart'

0 Kudos

M2 Change stock status to out-of-stock when qty is less than 'Minimum Qty Allowed in Shopping Cart'

I'm running Magento 2.3.5.

 

Some of my products have Minimum Qty Allowed in Shopping Cart set to greater than one.

For example, product A has Minimum Qty Allowed in Cart: 7. Currently, the QTY of A is 10. Now a customer bought 7 of A and now QTY becomes 3. At this moment the status of this item is still In Stock, however, customers can't add it to the cart and the error will pop up saying the qty is greater than the stock.

 

A lot of my customers got confused. This is very annoying and this affects the user experience.

 

So I wanted to make the product 'out of stock' programmatically when qty is less than the 'Minimum Qty Allowed in Shopping Cart'. I tried to set the out of stock threshold to 6 to achieve this, but then it only allows people to buy 4 even though I have 10.

 

If I want to write a plugin or override some classes, where should I start with? Thank you!