So we've implemented a modification to the product quantity update in cart based on this solution from Demac Media.
If the customer tries to update the quantity of a product in cart that is greater than the available quantity then the idea of this modification is to set the quantity to the maximum available for that product.
Copy...
/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php
To...
/app/code/local/Mage/CatalogInventory/Model/Stock/Item.php
Modify function checkQuoteItemQty($qty, $summaryQty, $origQty = 0)
Find on line 589 (Magento 1.7), change...
if (!$this->checkQty($summaryQty) || !$this->checkQty($qty)) {
$message = Mage::helper('cataloginventory')->__('The requested quantity for "%s" is not available.', $this->getProductName());
$result->setHasError(true)
->setMessage($message)
->setQuoteMessage($message)
->setQuoteMessageIndex('qty');
return $result;
To...
if (!$this->checkQty($summaryQty) || !$this->checkQty($qty)) {
$message = Mage::helper('cataloginventory')->__('The requested quantity for "%s" is not available. However, we have added the available quantity to your basket.', $this->getProductName());
$result->setHasError(false)
->setOrigQty($this->getQty())
->setMessage($message)
->setQuoteMessage($message)
->setQuoteMessageIndex('qty');
return $result;
This is working great for products without any options, but if a associated product of a configurable is added to the cart, updating the quantity to one of which is greater than the available in inventory continues to yield the error message and doesn't update to the maximum available.
Any idea's on why the function modification above would not be working for associated products in the cart? Thanks in advance.