Serve Order Line Item Metafield Values in Email Notification, Limited to Specific Fields

Has anyone succesfully setup a Shopify Flow order notification email that contained variables referencing SPECIFIC metafields from the line items? So far, I can get it to serve ALL metafields associated with the line item, but not just the specific ones we want displayed. We are also using Bonify Custom Fields for these specific fields which, again DO show up, but in case that impacts things. Here are the variables referenced so far, where ITEM DETAILS TESTING is the section serving the specific metafield and alleviates error when removed. Error screenshot attached.

ORDER DETAILS

Order ID: {{order.id}}

Order Number: {{order.name}}

Customer name: {{order.customer.displayName}}

Shopify customer id: {{order.customer.id}}

Customer company:

Customer email: {{order.email}}

ITEM DETAILS

{% for lineItems_item in order.lineItems %} {{lineItems_item.name}}{% endfor %}

{% for lineItems_item in order.lineItems %}

{% for metafields_item in lineItems_item.product.metafields %}

{{metafields_item.value}}

{% endfor %}

{% endfor %}

ITEM DETAILS TESTING

{% for metafields_item in lineitems_item.product.metafields %}

{% if metafields_item.key == “custom_fields.template” %}

{{ metafields_item.value }}

{% endif %}

{% endfor %}

Hi

It looks like you’re missing a loop around the last block of code. It should look like:

{% for lineItems_item in order.lineItems %}

{% for metafields_item in lineItems_item.product.metafields %}

{% if metafields_item.key == "custom_fields.template" %}

{{ metafields_item.value }}

{% endif %}

{% endfor %}

{% endfor %}

Also of note, the initial snippet you posted used the variable lineitems_item instead of lineItems_item (capitalization on the second i is mismatched) so that is fixed too.

Hope that helps!