Question

I am looking at limiting customers to buying 1 bundle product at a time.

Is there a way of setting "Maximum Qty Allowed in Shopping Cart" for a bundle product.

I want to do this without limiting the individual products, so customers can buy as many of them separately.

Any ideas if this is possible, if so how do I implement this?

Was it helpful?

Solution

The core feature "Maximum qty" is tied to stock items, so it does not work with bundles (they don't have their own stock).

You have to develop it on your own.

For simple products, the check happens in Mage_CatalogInventory_Model_Stock_Item::checkQuoteItemQty():

if ($this->getMaxSaleQty() && $qty > $this->getMaxSaleQty()) {
    $result->setHasError(true)
        ->setMessage(
            Mage::helper('cataloginventory')->__('The maximum quantity allowed for purchase is %s.', $this->getMaxSaleQty() * 1)
        )
        ->setErrorCode('qty_max')
        ->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in requested quantity.'))
        ->setQuoteMessageIndex('qty');
    return $result;
}

It's called in Mage_CatalogInventory_Model_Observer::checkQuoteItemQty() and this is where I would add my own additional restrictions for bundles. Either with a rewrite or with an additional observer for the same event (sales_quote_item_qty_set_after):

  • check if item is bundle
  • if so, check if bundle qty is > 1 and in this case add error to quote just like in the original observer.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top