3

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?

3

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.
  • Thanks a lot thats enough for me to go off to get this implemented – Bobadevv Apr 12 '16 at 20:58
  • @Bobadevv can i get working model? – zus Feb 6 '18 at 5:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.