balanv
balanv

Reputation: 10898

is there any way to restrict out of stock products being added to shopping cart?

Consider this situation where we have one product "Laptop adapter" and its stock as shown in admin panel is 10.

If a user selects this "Laptop adapter" and chooses quantity 20, Magento will give out a warning message like "Requested quantity for *** is not available" and adds this product count 20 to the shopping cart...

Is there any way to restrict out of stock count to be added in Shopping Cart, so the result of above example should be only an error message, without adding count 20 to the Cart.

Upvotes: 0

Views: 1438

Answers (2)

Krista K
Krista K

Reputation: 21851

In our 1.4.2 install, there is a setting in Admin so that customers cannot add out-of-stock items to the cart. We use this however, my Gal Friday does it, not me.

Upvotes: 0

Anton S
Anton S

Reputation: 12750

One way would be to override and extend the Mage_Checkout_CartController with your own controller method and rewrite the addAction() to something similar

public function addAction(){
    if(items are out of stock condition){
        $this->_getSession()->addException($e, $this->__('your out of stock notice.'));
        $this->_goBack();
    }
    parent::addAction();
}

Upvotes: 2

Related Questions