I am adding products in cart programmatically. But whenever I enter quantity more than available, it gives me a 503 error. e.g. Lets say a product has 7 quantity saved in admin and out of 7, 3 is already added into cart. So now 4 quantity is available. But if I try to add more than 4 it gives me 503 error.
Now I want to add a check for quantity before adding into the cart. Is it possible?
I am using below code to add product into cart.
$_product = Mage::getModel('catalog/product')->load(1); $cart = Mage::getModel('checkout/cart'); $cart->init(); $cart->addProduct($_product, array('qty' => 5); $cart->save(); Mage::getSingleton('checkout/session')->setCartWasUpdated(true);