Answers.Body: <p>You should be able to handle this with some logic in a plugin listening to events like:</p>
  
  <p><a href="https://craftcommerce.com/docs/events-reference#commerce_cart.onbeforeaddtocart" rel="nofollow noreferrer">https://craftcommerce.com/docs/events-reference#commerce_cart.onbeforeaddtocart</a></p>
  
  <p>The parameters for this include both the <code>order</code> as it stands, and the <code>lineItem</code> being added to the cart, which gives you the opportunity to manipulate both.  You could clear the order, and chec the qty of the lineitem being added is 1 at this point (and change it if needed).</p>
  
  <p>Obviously it would be good to have some front end stuff in place limiting the quantity to 1 as well.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-02T22:24:40.050Z
Answers.LastActivityDate: 2017-02-02T22:24:40.050Z
Answers.UserDisplayName: Jeremy Daalder
Body: <p>I’m using the Digital Products plugin to sell licenses so that users are listed on the site for a certain amount of time.</p>
  
  <p>The options are something like "buy 3 month", "buy 6 month" etc. You see, the concept of the cart doesn’t really apply here. There would be no point in buying "3 month" twice.</p>
  
  <p>That’s why I’d like to set the items in the cart always to the quantity of 1. Even better would be if I could empty the cart each time a product is added to the cart. That’s because people are supposed to select between the given options, not buying several options at once or multiple times.</p>
  
  <p>Any hints?</p>
  
Tags: <plugin-craftcommerce><plugin-digitalproducts>
Title: Set a maximum quantity for cart items
ThreadText: # Set a maximum quantity for cart items
  
  (Asked by: username_0 on 2017-01-31)
  
  I’m using the Digital Products plugin to sell licenses so that users are listed on the site for a certain amount of time.
  
  The options are something like "buy 3 month", "buy 6 month" etc. You see, the concept of the cart doesn’t really apply here. There would be no point in buying "3 month" twice.
  
  That’s why I’d like to set the items in the cart always to the quantity of 1. Even better would be if I could empty the cart each time a product is added to the cart. That’s because people are supposed to select between the given options, not buying several options at once or multiple times.
  
  Any hints?
  
  **Tags:** plugin-craftcommerce, plugin-digitalproducts
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-02-02. Score: 2 | Accepted answer
  
  You should be able to handle this with some logic in a plugin listening to events like:
  
  <https://craftcommerce.com/docs/events-reference#commerce_cart.onbeforeaddtocart>
  
  The parameters for this include both the `order` as it stands, and the `lineItem` being added to the cart, which gives you the opportunity to manipulate both. You could clear the order, and chec the qty of the lineitem being added is 1 at this point (and change it if needed).
  
  Obviously it would be good to have some front end stuff in place limiting the quantity to 1 as well.
  
  
  ---
  
  