Shopify themes, liquid, logos, and UX
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?
Solved! Go to the solution
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
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 -
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
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
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?
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024