<p>I might be misunderstanding your situation, but Commerce has built-in min/max &quot;Allowed Quantity&quot; per product (per variant technically) here: <a href="https://i.sstatic.net/emgN2.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/emgN2.png" alt="enter image description here" /></a></p>
<p>Limiting that to 1 max will prevent more from being added to the cart. You'll just need to handle error messages at your end, naturally.</p>

CC BY-SA 4.0
2023-11-23T15:34:53.393Z
Talk about overthinking the issue! I thought it would have to be done in code.

I'll keep that in mind, but I think in this site's case the owners may not like the idea of going through every variant to set a max.
Jaytrix
CC BY-SA 4.0
2023-11-23T14:05:11.953Z
2023-11-23T14:05:11.953Z
James Smith
<p>I found a coded solution using <a href="https://craftcms.com/docs/commerce/3.x/extend/events.html#beforesavelineitem" rel="nofollow noreferrer">EVENT_BEFORE_SAVE_LINE_ITEM</a></p>
<p>... but I think @JamesSmith's answer would be the ideal solution</p>

CC BY-SA 4.0
2023-11-23T15:34:19.553Z
2023-11-23T15:34:19.553Z
Jaytrix
<p>I have a site where the owners want to stop customers from ordering more than 1 type of item.</p>
<p>The Twig logic is already in place to stop any forms showing that would allow customers adding more than type, which is fine for when navigating between pages.
If a customer opens a product on several tabs, they can add multiples of the product.</p>
<p>I had gone through the route listening for the <code>EVENT_BEFORE_ADD_LINE_ITEM</code>, but I think this isn't occurring as once a product is added to the cart any further products of this type aren't new line items, they are quantity changes.</p>
<p>Is there an event to listen to for quantity changes for the cart?</p>

CC BY-SA 4.0
2023-11-24T04:05:49.790Z
I'm guessing that you meant to write that you want to stop customers from ordering more than 1 _of a single_ type of item, right? From the first paragraph of your question, I thought you were saying that an order must consist of only one line item, but that line item can have any quantity.
Sophie Swett
<craft3><plugin-craftcommerce><events>
Stop customers from increasing line item
# Stop customers from increasing line item

(Asked by: username_0 on 2023-11-23)

I have a site where the owners want to stop customers from ordering more than 1 type of item.

The Twig logic is already in place to stop any forms showing that would allow customers adding more than type, which is fine for when navigating between pages.
If a customer opens a product on several tabs, they can add multiples of the product.

I had gone through the route listening for the `EVENT_BEFORE_ADD_LINE_ITEM`, but I think this isn't occurring as once a product is added to the cart any further products of this type aren't new line items, they are quantity changes.

Is there an event to listen to for quantity changes for the cart?

**Tags:** craft3, plugin-craftcommerce, events
> **Comments:**
> **username_1**: I'm guessing that you meant to write that you want to stop customers from ordering more than 1 _of a single_ type of item, right? From the first paragraph of your question, I thought you were saying that an order must consist of only one line item, but that line item can have any quantity.  

---

## 2 answers

### Answer by username_2 on 2023-11-23. Score: 2

I might be misunderstanding your situation, but Commerce has built-in min/max "Allowed Quantity" per product (per variant technically) here: [![enter image description here](https://i.sstatic.net/emgN2.png)](https://i.sstatic.net/emgN2.png)

Limiting that to 1 max will prevent more from being added to the cart. You'll just need to handle error messages at your end, naturally.

> **Comments:**
> **username_0**: Talk about overthinking the issue! I thought it would have to be done in code.  I'll keep that in mind, but I think in this site's case the owners may not like the idea of going through every variant to set a max.  

---

### Answer by username_0 on 2023-11-23. Score: 1

I found a coded solution using [EVENT\_BEFORE\_SAVE\_LINE\_ITEM](https://craftcms.com/docs/commerce/3.x/extend/events.html#beforesavelineitem)

... but I think @JamesSmith's answer would be the ideal solution


---

