Magento: limit product max quantity to 1 per order. quantity 2 = 2 orders

Magento: limit product max quantity to 1 per order. quantity 2 = 2 orders

September 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: limit product max quantity to 1 per order. quantity 2 = 2 orders

Limiting Product Quantity Per Order in Magento

Hello! I’d be happy to help you set up this functionality in your Magento store. The ability to restrict certain products to one per order can indeed streamline later order processing workflows.

Understanding the Requirement

You want to ensure that specific products, say Product A and B, can only be ordered once at a time. If a customer wants to purchase these items twice, they will need to create two separate orders. This is particularly useful when you have inventory tracking or unique order requirements for certain SKUs.

Step-by-Step Solution

1. Create Custom Configurable Attribute

First, let’s create a new attribute that defines whether a product can be ordered only once per order. This will allow us to apply the restriction across multiple products.

  • Navigate to Stores > Attributes > Product.
  • Click on “Add New Attribute”.
  • Set the attribute name as “OrderLimitPerCustomer” and select Data Type as “Text Field”.
  • Save the attribute.

2. Modify Order Limit Functionality

Next, we need to modify the order placement logic in Magento to enforce this new rule. We’ll do this by overriding the Mage_Sales_Model_Quote_Item class.

Create a custom module and override the Mage_Sales\Model/Quote/Item.php file. In your custom file, add the following code:

class Mycompany_Sales_Model_Quote_Item extends Mage_Sales_Model_Quote_Item
{
    public function canBuy()
    {
        $result = parent::canBuy();

        // Check if this product has the 'OrderLimitPerCustomer' set to 1
        if ($this->getProduct()->getData('order_limit_per_customer') == 1) {
            $customerId = Mage::getSingleton('customer/session')->getCustomerId();
            $orderCollection = Mage::getResourceModel('sales/order_item_collection')
                ->addFieldToFilter('quote_id', $this->getQuoteItemId())
                ->addFieldToFilter('product_id', $this->getProduct()->getId());

            if (count($orderCollection) >= 1 && $customerId > 0) {
                return false;
            }
        }

        return $result;
    }
}

This code checks if the current product has the “OrderLimitPerCustomer” attribute set to 1. If it does, and an existing order for this customer already contains this item, then the canBuy() method returns false, preventing the addition of the item to the cart.

3. Assigning the Attribute

Now that our custom code is in place, we need to assign the “OrderLimitPerCustomer” attribute to the products that require this restriction.

  • Navigate to Catalog > Manage Products.
  • Edit a product (e.g., Product A).
  • In the “Custom Design” tab, scroll down to find the “Order Limit per Customer” field.
  • Set its value to 1 if you want to restrict it to one per order.
  • Save the product.

4. Clearing Cache

After making these changes, make sure to clear your Magento cache by navigating to System > Cache Management and clicking on the “Flush Magent Caches” button.

Conclusion

With this setup, specific products in your Magento store will now be restricted to one per order. This limitation applies on a per-customer basis.

Remember that this is a custom solution that requires some development knowledge. If you’re not comfortable making these changes yourself or if you have other complex requirements, I would recommend reaching out to our professional services at Laravel Company.

Our team specializes in Magento development and can help you implement this solution cleanly and efficiently in your production environment. Don’t hesitate to contact us for any assistance!

Happy selling!

Catalog API Extensions Configuration

Our network