logic in order confirmation

Topic summary

A user wants to display a product’s ship-out date (stored as a metafield) in Shopify’s order confirmation email but encounters issues because email templates cannot directly access product metafields.

The Core Problem:

  • Shopify notification templates only access order-level data, not product metafields
  • The metafield must be converted into a line item property during checkout to appear in emails

Recommended Solution (2-step process):

  1. In the product form (main-product.liquid or similar):

    • Add a hidden input field that captures the metafield value as a cart property
    • Code: <input type="hidden" name="properties[Ship out date]" value="{{ product.metafields.custom.ship_out_date }}">
  2. In the email template (order_confirmation):

    • Add logic within the line items loop to display the property
    • Code: {% if line.properties["Ship out date"] %} Ship Out Date: {{ line.properties["Ship out date"] }} {% endif %}

Current Status:

  • User successfully implemented step 1 but struggles with step 2
  • Needs help locating the “title section” and “line_items loop” in the email template
  • The discussion remains open with the user requesting specific placement guidance for the email template code
Summarized with AI on October 27. AI used: claude-sonnet-4-5-20250929.

hi, I want to add ship out date under title product in email confirmation

but when I edit email template code to add metafield and sending test

that metafield not appear in order confirmation

can you show me how to add this logic and where to place in template email? or do I have to put it on theme as well?

1 Like

Hello @cc05

Which type of metafield’s value do you want to show (order metafield or product metafield)?

Hello @cc05

To show a custom metafield like a ship-out date in the order confirmation email (transactional emails), you’ll run into a limitation: Shopify’s notification templates cannot access product metafields directly.

Here’s a breakdown of what you can do and how to work around it.

Why the metafield isn’t showing
Shopify’s order confirmation email (order_confirmation) only has access to:

. line_item

. product.title

. line_item.variant

. line_item.properties (from custom line item properties like product form inputs)

It does NOT have access to product metafields. That data lives outside the order scope and is not accessible inside the email notification logic.

Workaround Option 1: Use line_item.properties via product form (Recommended)
If you control the product page, you can pull the metafield value (ship out date) into the product form as a hidden field, so it’s saved to the order and becomes accessible in the email.

  1. Add metafield to product form in theme
    In your product template (e.g. product.liquid or main-product.liquid in Dawn), add:
{% if product.metafields.custom.ship_out_date %}
  
{% endif %}

Make sure:

. custom is the namespace

. ship_out_date is the key

  1. Update email template (order_confirmation)
    In the email template (under Settings > Notifications > Order confirmation), add this logic inside the line_items loop:
{% for line in line_items %}
  

**{{ line.title }}**

  {% if line.properties["Ship out date"] %}
    

Ship Out Date: {{ line.properties["Ship out date"] }}

  {% endif %}
{% endfor %}

Alternative Option 2: Store metafield data in a note attribute (manual or via app/script)
If you’re not using custom properties in the cart, but you’re pre-processing orders via a custom app or automation, you could:

. Copy the product metafield into the order’s note attributes or line item properties before the order is confirmed.

. Then show it using the same logic above.

Can this be done only via theme or metafield edit?
No — just editing the metafield on the product level or modifying the email template alone won’t work, because the metafield isn’t part of the order object.

Thank you :blush:

I create it as product metafield because I want it to show on collection product and product page

Hello @cc05

Got it — if you’re using a product metafield, no worries! You can definitely display the metafield value in your email template. By default, though, we can’t directly fetch product metafields on the Thank You page. So, you’ll need to pass that metafield value as a cart line item property first.

Here’s how you can do it:
1. Add the metafield value to your product form
Locate your product form in the buy-button.liquid file (if you’re using the Dawn theme). The form will look something like this:

{%- form 'product',
product,
id: product_form_id,
class: 'form',
novalidate: 'novalidate',
data-type: 'add-to-cart-form'
-%}

Inside this form, add the following code:

{% if product.metafields.custom.ship_out_date %}

{% endif %}

Save the file once you’ve added this.

2. Update your email template
Now, open your email template and search for line.product — you’ll find product title-related code multiple times. After the title section, insert this code to display the Ship Out Date:

{% if line.properties["Ship out date"] %}

Ship Out Date: {{ line.properties["Ship out date"] }}

{% endif %}

If you’re specifically editing the Order Confirmation Email template, find this line:

{{ line_title }}

And paste the Ship Out Date code right after that .

Note: Please use the metafield name that you have created on your admin side.

If you follow these steps, then you can easily showcase the metafield value on your email template.

Thanks

If I did not use dawn theme, how can I locate this form

{%- form ‘product’, product, id: product_form_id, class: ‘form’, novalidate: ‘novalidate’, data-type: ’

I success on number 1 Add the metafield value to your product form

this is a code I put on my main-product.liquid



{% if product.metafields.custom.ship-out_date %}

{% endif %}

but when I try to 2. Update email template ship out date it’s not showing

I think I don’t know how to locate “After the title section” as you said

this is a code I try to put on email template



{% if line.properties[“Ship out”] %}



Ship Out Date: {{ line.properties[“Ship out”] }}





{% endif %}

Could you help me locate the title section? and how many place that I have to put code on?

Can I ask that where is “line_items loop” ?