Show content in email notification based on product metafield boolean

Solved

Show content in email notification based on product metafield boolean

tony-smith
Shopify Partner
1 0 0

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.

 
Accepted Solution (1)

Liam
Community Manager
3108 341 880

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

View solution in original post

Replies 2 (2)

Liam
Community Manager
3108 341 880

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

jayneK
Visitor
1 0 0
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。