Re: Add product metafield to email order confirmation

Solved

Add product metafield to email order confirmation

annenetmine
Visitor
3 0 0

Hi! 
I have read all the treads about this but cant make it work :))

 

I have an produkt metafields, witch is named: custom.event_info_test

 

I want to show this in the order confirmation email... But how?

Accepted Solution (1)

JoesIdeas
Shopify Partner
2395 220 635

This is an accepted solution.

You can access product metafields with the line.product.metafields variable.


Example: 

{% for line in line_items %}
<p>{{ line.product.metafields }}</p>
{% endfor %}

 

To show a specific metafields, you can use this variable: {[ line.product.metafields.NAMESPACE.KEY }}

 

So, assuming "custom" is the namespace and "event_info_test" is the key, you could access that metafield with this variable:

{[ line.product.metafields.custom.event_info_test }}

 

Reference docs:

https://help.shopify.com/en/manual/orders/notifications/email-variables

https://shopify.dev/docs/api/liquid/objects/metafield

 

• Creator of Shopify automation apps Order Automator + Product Automator [apps that save you time + money]
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Figure Out Why You're Not Getting Sales

View solution in original post

Replies 3 (3)

Vivek_goyal
Shopify Partner
49 4 14

Hi @annenetmine,

 

To show product metafield value in your order confirmation email you need to edit the "Order Confirmation" template. 

To access "Order Confirmation" template follow these steps -

  1. Go to Shopify admin > Settings > Notifications
  2. Select the "Customer Notifications" section
  3. Click on the "Order confirmation" 
  4. Click on the "Edit code" to open the template 

Now, here in the template you can add you metafield to be displayed.

 

For editing the liquid code, here is reference video link to edit printing slip template to display custom field value of the product:  https://www.youtube.com/watch?v=aMN49-AZLYI 

 

This will give you an idea of how to edit template and use liquid variables.

 

Please let me know if more details are needed.

 

Thanks & Regards,

Vivek

Product Designer & Variants: Create custom products with ease. (Try for free)
Need a Shopify developer? Hire Us
Email: info@scaleupprint.com For Shopify tips & tricks follow our YouTube channel

JoesIdeas
Shopify Partner
2395 220 635

This is an accepted solution.

You can access product metafields with the line.product.metafields variable.


Example: 

{% for line in line_items %}
<p>{{ line.product.metafields }}</p>
{% endfor %}

 

To show a specific metafields, you can use this variable: {[ line.product.metafields.NAMESPACE.KEY }}

 

So, assuming "custom" is the namespace and "event_info_test" is the key, you could access that metafield with this variable:

{[ line.product.metafields.custom.event_info_test }}

 

Reference docs:

https://help.shopify.com/en/manual/orders/notifications/email-variables

https://shopify.dev/docs/api/liquid/objects/metafield

 

• Creator of Shopify automation apps Order Automator + Product Automator [apps that save you time + money]
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Figure Out Why You're Not Getting Sales
annenetmine
Visitor
3 0 0

Oh! I had tried to use that varible before but i havent use the "{% for line in line_items %}" to check before. Now it works great!

 

Thank you so much! Really appriciate it- 😃

But now I have a follow-up problem. I have several variations of this product and I only want to read this metafield once per product in the email, not once per variant. How can I adjust this?