logic in order confirmation

logic in order confirmation

cc05
Visitor
2 0 1

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?

 

Replies 4 (4)

tapan_sain
Shopify Partner
25 3 6

Hello @cc05 

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

Tapan sain
cc05
Visitor
2 0 1

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

tapan_sain
Shopify Partner
25 3 6

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 %}
<input type="hidden" name="properties[Ship out date]" value="{{ 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"] %}
<p>Ship Out Date: {{ line.properties["Ship out date"] }}</p>
{% endif %}


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

<span class="order-list__item-title">{{ line_title }}</span>


And paste the Ship Out Date code right after that </span>.


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

Tapan sain

goldi07
Navigator
360 38 69

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 %}
  <input type="hidden" name="properties[Ship out date]" value="{{ product.metafields.custom.ship_out_date.value }}">
{% endif %}

Make sure:

. custom is the namespace

. ship_out_date is the key

 

2. 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 %}
  <p><strong>{{ line.title }}</strong></p>

  {% if line.properties["Ship out date"] %}
    <p>Ship Out Date: {{ line.properties["Ship out date"] }}</p>
  {% 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 😊

Was I helpful?

Buy me a coffee


APPS BY US :

Professional Customer Accounts APP


Want to modify or custom changes or bug fix on store . Or Need help with your store? Or -Want Complete Storefront
Email me -Goldi184507@gmail.com - Skype: live:.cid.819bad8ddb52736c -Whatsapp: +919317950519
Checkout Some Free Sections Here