Magento – How to limit product max quantity per customer

magento-1.9module

i have a problem with the configuration of the stock, im explain: I need limit the product max qty per customer, the shop need sells certain qty of products per customer, this shop have 40 customers and need distribute the general stock to each customer, how i can do it?, i hope can help me guys! thanks for ur time! have a great day!

Best Answer

To restrict the qty use the setting Maximum Qty Allowed in Shopping Cart to 1

enter image description here

If you want to additionally check for previous orders of this item and prevent them being added to the cart you could solve this similar to my answer here https://magento.stackexchange.com/a/9606/9

And then in your observer class

<?php

class Fooman_Example_Model_Observer
{
    public function catalogProductTypePrepare($observer)
    {
        $customerId = Mage::getSingleton('customer/session')->getCustomerId();
        $product = $observer->getEvent()->getProduct();
        //Add code here to look up previous orders
        if($orderedBefore){
            Mage::throwException('You can only buy this product once.');
        }
    }
}