Answers.Body: <p>Add a custom plain text field to your orders, say <code>test</code>.</p>
  
  <p>Then, when calling <code>updateCart</code>, you can add data in to this custom field using a form with an input named like this:</p>
  
  <pre><code>  &lt;input name="fields[test]" type="text"&gt; etc...
  </code></pre>
  
  <p>This data will then get saved with the order.  This same approach can basically be applied to any field/type.</p>
  
  <p>To actually validate the data, you'll need to look to making a plugin, most likely listening to onBeforeSaveOrder to check the vailidity of the data.  If valid, great, if not, set <code>perfomAction</code> to false and return an error on the Order model.  </p>
  
  <p>See <a href="https://craftcommerce.com/docs/events-reference#commerce_orders.onbeforesaveorder" rel="nofollow">https://craftcommerce.com/docs/events-reference#commerce_orders.onbeforesaveorder</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-21T19:32:01.813Z
Answers.Text: I've been trying this but the custom field/val never gets saved to the order model after calling updateCart. Are you saying that I would look for the form's custom field->value through the onbeforesaveorder event and do everything from there? I was hoping there'd simply be a way to just add a new field/value to the order model without any logic from listening to an event.
Answers.UserDisplayName: taylor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-21T22:12:14.090Z
Answers.Text: You only need the plugin for validation. The field data should save with any update of the cart. Maybe post your input and output code?
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-20T05:26:10.773Z
Answers.LastActivityDate: 2016-10-20T05:26:10.773Z
Answers.UserDisplayName: Jeremy Daalder
Body: <p>I have shipping methods that will require additional information from the user. For example, a local delivery <code>shipping method</code> which requires the user to include a timeframe for delivery (say, Thursday @ 3pm.)</p>
  <p>I thought I'd go about it doing something like this:</p>
  <hr />
  <ol>
  <li>On select shipping page during checkout, user selects the delivery date/time (based on what is available.)</li>
  <li>User selects date, then submits form.</li>
  <li><strong>That date is attached somewhere to the order model.</strong></li>
  <li>The shipping method rules will validate the chosen date.</li>
  <li>Include this additional information (selected delivery date) in saved order on checkout completion.</li>
  </ol>
  <hr />
  <p>Is there a way to do this? Basically, I need to attach additional information for this shipping method (and another similar one.) I've looked through the <a href="https://craftcommerce.com/docs/order-model" rel="nofollow noreferrer">order model docs</a> but can't find a field I could add <em><strong>custom</strong></em> data to.</p>
  
Tags: <plugin-development><plugin-craftcommerce><shipping>
Title: Attach Custom Information to Commerce Order Model
ThreadText: # Attach Custom Information to Commerce Order Model
  
  (Asked by: username_0 on 2016-10-19)
  
  I have shipping methods that will require additional information from the user. For example, a local delivery `shipping method` which requires the user to include a timeframe for delivery (say, Thursday @ 3pm.)
  
  I thought I'd go about it doing something like this:
  
  ---
  
  1. On select shipping page during checkout, user selects the delivery date/time (based on what is available.)
  2. User selects date, then submits form.
  3. **That date is attached somewhere to the order model.**
  4. The shipping method rules will validate the chosen date.
  5. Include this additional information (selected delivery date) in saved order on checkout completion.
  
  ---
  
  Is there a way to do this? Basically, I need to attach additional information for this shipping method (and another similar one.) I've looked through the [order model docs](https://craftcommerce.com/docs/order-model) but can't find a field I could add ***custom*** data to.
  
  **Tags:** plugin-development, plugin-craftcommerce, shipping
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-10-20. Score: 4 | Accepted answer
  
  Add a custom plain text field to your orders, say `test`.
  
  Then, when calling `updateCart`, you can add data in to this custom field using a form with an input named like this:
  
  ```
    <input name="fields[test]" type="text"> etc...
  
  ```
  
  This data will then get saved with the order. This same approach can basically be applied to any field/type.
  
  To actually validate the data, you'll need to look to making a plugin, most likely listening to onBeforeSaveOrder to check the vailidity of the data. If valid, great, if not, set `perfomAction` to false and return an error on the Order model.
  
  See <https://craftcommerce.com/docs/events-reference#commerce_orders.onbeforesaveorder>
  
  > **Comments:**
  > **username_0**: I've been trying this but the custom field/val never gets saved to the order model after calling updateCart. Are you saying that I would look for the form's custom field->value through the onbeforesaveorder event and do everything from there? I was hoping there'd simply be a way to just add a new field/value to the order model without any logic from listening to an event.  
  > **username_1**: You only need the plugin for validation. The field data should save with any update of the cart. Maybe post your input and output code?  
  
  ---
  
  