Show content in email notification based on product metafield boolean

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.

Hi Tony,

If you replace {% for line in subtotal_line_items %} with {% for line in line_items %} will this work?

1 Like

Hello, I’d like to ask, which API event should we refer to in order to obtain user inquiry messages? I’ve been searching for a while but I’m not sure if there’s an API available for retrieving chat messages between merchants and users. We want to implement a feature where merchants can receive messages from users via email within our application, and respond to them through our system. Can you assist me?maybe like shopiftchat。