A space to discuss online store customization, theme development, and Liquid templating.
I have two metafields on a product to toggle if the product is a pre-order and also an expected delivery date.
I can get the delivery date pulled into the email notification, however, my code to query the Boolean of the pre-order field doesn't seem to work in the email notification. Yet the same code works on the product template.
Here is my code:
{% for line in subtotal_line_items %} {% if line.product.metafields.custom.preorder %} <p style="font-weight: bold;color:#ff0000;">IMPORTANT:<br/> Your order contains a pre-order item.<br/>Your order will ship by {{ line.product.metafields.custom.release_date | date: "%B %d" }} or earlier.<br/><br/></p> {% break %} {% endif %} {% endfor %}
Additionally in my testing, when I change the date on the product it can take a few hours to register in my test email notification. I would have assumed updating a metafield would update instantly in the email notification tests.
To test my code above I placed two live orders and tried the 'resend email' option in Shopify admin as it appears to grab the latest code for the order notification email.
Solved! Go to the solution
This is an accepted solution.
Hi Tony,
If you replace `{% for line in subtotal_line_items %}` with `{% for line in line_items %}` will this work?
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hi Tony,
If you replace `{% for line in subtotal_line_items %}` with `{% for line in line_items %}` will this work?
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog