3

Is it anyhow possible to limit specific products in Magento to a max quantity of one per order? This means the user can only order one product at a time. If he wants to order the product twice he has to do a second order. This is very important for me for the later order workflow.

Thx for your help, I appreciate it!

Kind regards, Manu

Manuel
  • 9,112
  • 13
  • 70
  • 110

4 Answers4

9

Yes, you can limit the maximum quantity of a product in the shopping cart by editing the value on the Inventory tab when editing a product. See screenshot below. In your case, you'd want to uncheck Use Config Settings and set the value to 1.

Product page Inventory tab

nachito
  • 6,975
  • 2
  • 25
  • 44
  • 1
    ok, maybe I was not specific enough. I meant a total of 1 product can be ordert. Your configuration only limits a specific product to be ordered once. – Manuel Jun 09 '12 at 17:36
  • This param means that you can buy 10000 at a time. One client can buy 10000 items per one order. If he wants then 1000 items again per next order. And so again and again. – vikcherniy Jun 22 '12 at 08:47
  • Yeah, I understand, but if I have 2 products (A and B) with max qty 1 I still can order 2 Products: 1x product A and 1x product B. However a customer should only be able to oder ONE product at all. So a customer can either order product A or product B. You know a solution for this too? – Manuel Jan 27 '13 at 15:23
  • 2
    I would suggest modifying `Mage_Checkout_Model_Cart::addProduct()` to disallow adding items if the cart already has quantity (see `getItemsQty()`). You should also be aware of `updateItem()` which could be used to change the quantity of items in one's cart. – nachito Jan 28 '13 at 00:23
2

Well above answer is useful to restrict a single product to add in cart not for Restricting Maximum Qty Allowed in Shopping Car. To change this setting fallow bellow steps.

First login into Magento admin then Go to System>>Configuration then use this configuration settings.

enter image description here

0

Take a look @ Magento Maximum Allowed Order Amount, you would have to create a custom module to add this feature.

Create an observer for sales_quote_save_before

<config>
    <frontend>
        <events>
            <sales_quote_save_before>
                <observers>
                    <inchoo_maxorderamount_enforceSingleOrderLimit>
                        <class>inchoo_maxorderamount/observer</class>
                        <method>enforceSingleOrderLimit</method>
                    </inchoo_maxorderamount_enforceSingleOrderLimit>
                </observers>
            </sales_quote_save_before>
        </events>
    </frontend>
</config>

In your observer

class Inchoo_MaxOrderAmount_Model_Observer
{
    private $_helper;
    public function __construct()
    {
        $this->_helper = Mage::helper('inchoo_maxorderamount');
    }
    /**
     * No single order can be placed over the amount of X
     */
    public function enforceSingleOrderLimit($observer)
    {
        if (!$this->_helper->isModuleEnabled()) {
            return;
        }
        $quote = $observer->getEvent()->getQuote();
        if ($quote->getCart()->getItemsCount() == 1) {

            Mage::getSingleton('checkout/session')->addError('limit only one product per order');
            Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
            Mage::app()->getResponse()->sendResponse();
            exit;
        }
    }
}
MagePal Extensions
  • 17,646
  • 2
  • 47
  • 62
  • For some reason its not displaying errors. I've set ini and error reporting options in index.php so I'm trying to figure out why its just a white screen now. – Thomas Bennett Feb 18 '15 at 20:43
0

The below should fix your issue:

public function enforceSingleOrderLimit($observer){
     if (!$this->_helper->isModuleEnabled()) {
        return;
    }
    $cart = Mage::getModel('checkout/cart')->getQuote();
    if ($cart->getItemsCount() > 1) {

        Mage::getSingleton('checkout/session')->addError('limit only one product per order');
        Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
        Mage::app()->getResponse()->sendResponse();
        exit;
    }
}