Hi all,
I am having great difficulty in pulling product metafields into email notifications. I have tried many things over the last few hours (and learnt a lot!), but I have reached the end where I believe I’m doing everything correct, yet it isn’t working.
The goal is to pull the value of a metafield from a product to display in a notification email (in particular the pick up notification email).
<table>
{% for line in line_items %}
{% endfor %}
<table>
<table>
<tr>
<td>
{% if line.image %}
{% endif %}
</td>
<td>
{% if line.product.title %}
{% assign line_title = line.product.title %}
{% else %}
{% assign line_title = line.title %}
{% endif %}
{% if line.quantity < line.quantity %}
{% capture line_display %}
{{ line.quantity }} of {{ line.quantity }}
{% endcapture %}
{% else %}
{% assign line_display = line.quantity %}
{% endif %}
{{ line_title }} × {{ line_display }}
{% if line.variant_title != 'Default Title' %}
{{ line.variant_title }}
Here is what I am trying to show: {{ line.product.metafield.custom.duration.value }} and {{ line.product.metafield.reviews.rating_count.value }}.
{% endif %}
</td>
</tr>
</table>
</table>
I am trying to pull these two metafields: {{ line.product.metafield.custom.duration.value }} and {{ line.product.metafield.reviews.rating_count.value }}.
- custom.duration is a single line text
- reviews.rating_count is a integer
- The thing I am actually trying to pull is a list of ‘single line texts’, yet I can’t even figure out the syntax to pull a single item, let alone setting up my for loop to include all the items from an array
- The one I tried with an array was {% for req as line.product.metafield.custom.requirements %} {{ req }}, {% endfor %} where line.product.metafield.custom.requirements is a list of single line text items.
Many thanks in advance and hoping someone can assist with where I’ve gone wrong!
Additionally, I have read and tried the things from the following threads/pages but obviously doing something wrong:
https://www.shopify.com/au/partners/blog/metafields
https://shopify.dev/docs/api/liquid/objects/metafield
https://shopify.dev/docs/apps/custom-data/metafields/manage-metafields#step-2-retrieve-a-metafield
https://community.shopify.com/topic/1151643
https://community.shopify.com/post/148358
https://community.shopify.com/topic/1787934