Answers.Body: <p>There are two ways of doing this: you can hook into the &quot;live&quot; product data using <code>{{ item.purchasable.product.articleNumber }}</code> -- and this is <em>probably</em> fine for the use-case of a confirmation email that presumably gets sent immediately. However, if you're outputting historic order data on the front end, or generating sales reports etc, then ideally you don't want to use the live data for this purpose - rather you want a static snapshot of the data as it was at the time of the order. That's what <code>{{ item.snapshot }}</code> is for, so I'd generally prefer that for safety.</p>
  <p>However, out of the box, <code>{{ item.snapshot.product }}</code> doesn't include any custom fields. To get your custom fields saved to the snapshot you need to save them to the cart during your add-to-cart form submissions. You need an array field named <code>options</code> which you can then add the data to like this:</p>
  <pre><code>&lt;input type=&quot;hidden&quot; name=&quot;options[articleNumber]&quot; value=&quot;123&quot;&gt;
  </code></pre>
  <p>Then you can retrieve that in the order with <code>{{ item.snapshot.options.articleNumber }}</code></p>
  <p>A better explanation of snapshots: <a href="https://craftcms.stackexchange.com/a/35658/271">https://craftcms.stackexchange.com/a/35658/271</a></p>
  <p>About line item options:
  <a href="https://craftcms.com/docs/commerce/3.x/orders-carts.html#line-item-options-and-notes" rel="nofollow noreferrer">https://craftcms.com/docs/commerce/3.x/orders-carts.html#line-item-options-and-notes</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-25T14:59:58.777Z
Answers.Text: thanks. this worked. but haven't really got the snapshot working. can not find anything in the docs: https://craftcms.com/docs/commerce/3.x/purchasables.html#purchasables-and-line-items
Answers.UserDisplayName: Henrik
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-25T15:15:40.517Z
Answers.Text: Sorry yes, I've edited the answer to explain further.
Answers.UserDisplayName: James Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-25T13:57:41.393Z
Answers.LastActivityDate: 2022-03-25T15:15:26.033Z
Answers.LastEditDate: 2022-03-25T15:15:26.033Z
Answers.UserDisplayName: James Smith
Body: <p>in my confirmation e-mail i output all ordered items.</p>
  <p>now i want to add a custom field (the article number) from a product,
  but it does not show up.</p>
  <p>i show items like this:</p>
  <p><code> {% for item in order.lineItems %}</code> and then for example
  <code>{{ item.qty }}</code>.</p>
  <p>But <code>{{ item.articleNumber }}</code> does not work.</p>
  <p>i also tried</p>
  <pre><code>{% set product = craft.products() %}
  {{ product.articleNumber }}
  </code></pre>
  
Tags: <emails><custom-field><plugin-craftcommerce3>
Title: Add custom field value to Commerce Order Confirmation E-Mail
ThreadText: # Add custom field value to Commerce Order Confirmation E-Mail
  
  (Asked by: username_0 on 2022-03-25)
  
  in my confirmation e-mail i output all ordered items.
  
  now i want to add a custom field (the article number) from a product,
  but it does not show up.
  
  i show items like this:
  
  `{% for item in order.lineItems %}` and then for example
  `{{ item.qty }}`.
  
  But `{{ item.articleNumber }}` does not work.
  
  i also tried
  
  ```
  {% set product = craft.products() %}
  {{ product.articleNumber }}
  
  ```
  
  **Tags:** emails, custom-field, plugin-craftcommerce3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-03-25. Score: 3 | Accepted answer
  
  There are two ways of doing this: you can hook into the "live" product data using `{{ item.purchasable.product.articleNumber }}` -- and this is *probably* fine for the use-case of a confirmation email that presumably gets sent immediately. However, if you're outputting historic order data on the front end, or generating sales reports etc, then ideally you don't want to use the live data for this purpose - rather you want a static snapshot of the data as it was at the time of the order. That's what `{{ item.snapshot }}` is for, so I'd generally prefer that for safety.
  
  However, out of the box, `{{ item.snapshot.product }}` doesn't include any custom fields. To get your custom fields saved to the snapshot you need to save them to the cart during your add-to-cart form submissions. You need an array field named `options` which you can then add the data to like this:
  
  ```
  <input type="hidden" name="options[articleNumber]" value="123">
  
  ```
  
  Then you can retrieve that in the order with `{{ item.snapshot.options.articleNumber }}`
  
  A better explanation of snapshots: <https://craftcms.stackexchange.com/a/35658/271>
  
  About line item options:
  <https://craftcms.com/docs/commerce/3.x/orders-carts.html#line-item-options-and-notes>
  
  > **Comments:**
  > **username_0**: thanks. this worked. but haven't really got the snapshot working. can not find anything in the docs: https://craftcms.com/docs/commerce/3.x/purchasables.html#purchasables-and-line-items  
  > **username_1**: Sorry yes, I've edited the answer to explain further.  
  
  ---
  
  