Answers.Body: <p>You will need to make use of lineitem "options" param. You can attach as many options as you like using something like:</p>
  
  <pre><code>&lt;input type="number" name="options[numberDistance]" step="any" placeholder="Add your minimum distance in mm..." id="distanceNum"&gt;
  </code></pre>
  
  <p>And then these will be avaliable on the lineItem once saved using</p>
  
  <p><code>{{ item.options['numberDistance'] }}</code></p>
  
  <p>More info can be found on the <a href="https://craftcommerce.com/docs/add-to-cart#line-item-options-and-notes" rel="nofollow">Craft Commerce docs</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-21T16:00:11.753Z
Answers.LastActivityDate: 2016-06-21T16:07:01.933Z
Answers.LastEditDate: 2016-06-21T16:07:01.933Z
Answers.UserDisplayName: Luke Pearce
Body: <p>I'm adding the following to my <code>_product.html</code> template to try and add a number to a line item in the same way that notes are added. I'm using the following input:</p>
  
  <pre><code>&lt;input type="number" name="numberDistance" step="any" placeholder="Add your minimum distance in mm..." id="distanceNum"&gt;
  </code></pre>
  
  <p>I then add the following to my cart template to output the field:</p>
  
  <pre><code>Min distance: {{ item.numberDistance }}
  </code></pre>
  
  <p>When I add an item to my cart I get the following error:</p>
  
  <p><strong>Craft\Commerce_LineItemModel and its behaviors do not have a method or closure named "numberDistance".</strong></p>
  
  <p>What is going wrong and how do I fix this?</p>
  
Tags: <plugin-craftcommerce>
Title: Craft Commerce: Adding Number fields to product and cart pages
ThreadText: # Craft Commerce: Adding Number fields to product and cart pages
  
  (Asked by: username_0 on 2016-06-21)
  
  I'm adding the following to my `_product.html` template to try and add a number to a line item in the same way that notes are added. I'm using the following input:
  
  ```
  <input type="number" name="numberDistance" step="any" placeholder="Add your minimum distance in mm..." id="distanceNum">
  
  ```
  
  I then add the following to my cart template to output the field:
  
  ```
  Min distance: {{ item.numberDistance }}
  
  ```
  
  When I add an item to my cart I get the following error:
  
  **Craft\Commerce\_LineItemModel and its behaviors do not have a method or closure named "numberDistance".**
  
  What is going wrong and how do I fix this?
  
  **Tags:** plugin-craftcommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-06-21. Score: 2 | Accepted answer
  
  You will need to make use of lineitem "options" param. You can attach as many options as you like using something like:
  
  ```
  <input type="number" name="options[numberDistance]" step="any" placeholder="Add your minimum distance in mm..." id="distanceNum">
  
  ```
  
  And then these will be avaliable on the lineItem once saved using
  
  `{{ item.options['numberDistance'] }}`
  
  More info can be found on the [Craft Commerce docs](https://craftcommerce.com/docs/add-to-cart#line-item-options-and-notes)
  
  
  ---
  
  