Answers.Body: <p>Given how much of Commerce internally will be relying on whole number quantities, I think option 2 is the far better plan. </p>
  
  <p>You can't add custom fields to line items currently, and while you might be able to hack something using the options/notes systems, or custom order fields on the order as a whole, I'd think this would get complex to maintain quickly. Best to use your minimum selling measure as the unit and dress it up front end.... that should work well and will be substantially easier to implement and (importantly) maintain. </p>
  
  <p>With stores, even more than websites, long term ease of understanding and maintenance should be a high priority goal. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-23T21:57:33.137Z
Answers.LastActivityDate: 2016-11-23T21:57:33.137Z
Answers.UserDisplayName: Jeremy Daalder
Body: <p>I am making a custom store that can sell half pounds of items. I've noticed through sending calls through my plugin to the <code>craft()-&gt;commerce_cart-&gt;addToCart($cart, $itemNumber, $qty);</code> to add an item to an order while specifying a non-integer quantity gives me the error: <strong>"Qty must be an integer"</strong></p>
  
  <p>Is there any way to allow quantity to be a non-integer? Customers will be ordering in .5 pound increments occasionally. I am not anemic to plugin development and php so I thought I'd ask the community if there was a way around this, or if I'm stuck with Qty being an integer.</p>
  
  <p>Couple other options I've though of:</p>
  
  <ol>
  <li>Make a custom field to deal with qty</li>
  <li>Split my items into .5 increments so someone adding 5.5 lbs would really be adding qty 11 and there'd be special things going on with the admin and front-end to hide that fact</li>
  </ol>
  
Tags: <plugin-development><plugin-craftcommerce><custom-field>
Title: Non Integer Quantities in Craft Commerce
ThreadText: # Non Integer Quantities in Craft Commerce
  
  (Asked by: username_0 on 2016-11-23)
  
  I am making a custom store that can sell half pounds of items. I've noticed through sending calls through my plugin to the `craft()->commerce_cart->addToCart($cart, $itemNumber, $qty);` to add an item to an order while specifying a non-integer quantity gives me the error: **"Qty must be an integer"**
  
  Is there any way to allow quantity to be a non-integer? Customers will be ordering in .5 pound increments occasionally. I am not anemic to plugin development and php so I thought I'd ask the community if there was a way around this, or if I'm stuck with Qty being an integer.
  
  Couple other options I've though of:
  
  1. Make a custom field to deal with qty
  2. Split my items into .5 increments so someone adding 5.5 lbs would really be adding qty 11 and there'd be special things going on with the admin and front-end to hide that fact
  
  **Tags:** plugin-development, plugin-craftcommerce, custom-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-11-23. Score: 1 | Accepted answer
  
  Given how much of Commerce internally will be relying on whole number quantities, I think option 2 is the far better plan.
  
  You can't add custom fields to line items currently, and while you might be able to hack something using the options/notes systems, or custom order fields on the order as a whole, I'd think this would get complex to maintain quickly. Best to use your minimum selling measure as the unit and dress it up front end.... that should work well and will be substantially easier to implement and (importantly) maintain.
  
  With stores, even more than websites, long term ease of understanding and maintenance should be a high priority goal.
  
  
  ---
  
  