Order Confirmation Email: How to use Line Item conditions?

Solved

Order Confirmation Email: How to use Line Item conditions?

Hugo_Jones
Shopify Partner
5 0 4

I've been attempting to use basic line item conditions in my order confirmation email but I consistently receive no output in my test emails.

 

I feel like I'm missing something fundamental because what I'm attempting seems trivial. I've been poking around the forums and YouTube but I can't seem to get the right leads on this topic.

 

Below are some examples of basic conditions I've tried. Any help/tip is appreciated!

 

Example #1

{% if line.product.vendor contains 'Amazon' %}
Vendor is Amazon!
{% endif %}

Example #2

{% if line.product.title == 'Test' %}
Product's title is Test!
{% endif %}     

 

️ Update:

After much testing I found that if I sandwiched the above examples between the following code it works!

{% for line in subtotal_line_items %}
{% endfor %}

 Though I don't know why. Thoughts anyone?

Accepted Solution (1)

Uhrick
Shopify Partner
433 68 102

This is an accepted solution.

Hello, Hugo_Jones.

 

Basically, what your first two pieces of code were doing was:

If line item has/is this, do that

the problem is that line item wasn't defined anywhere.

When you add 

{% for line in subtotal_line_items %}
{% endfor %}

you are looping through the existent subtotal line items, which are already defined, and you are defining each item being looped with the name 'line', that you were already using, then, you do this

If line item has/is this, do that

verification for each one of the line items, that's the reason that it works now. Let me know if I was clear enough

Shopify Developer
Hire me for theme customizations at ricardomsilvestre@outlook.com or Upwork
Was my answer helpful to you? Please like or mark as solution

View solution in original post

Reply 1 (1)

Uhrick
Shopify Partner
433 68 102

This is an accepted solution.

Hello, Hugo_Jones.

 

Basically, what your first two pieces of code were doing was:

If line item has/is this, do that

the problem is that line item wasn't defined anywhere.

When you add 

{% for line in subtotal_line_items %}
{% endfor %}

you are looping through the existent subtotal line items, which are already defined, and you are defining each item being looped with the name 'line', that you were already using, then, you do this

If line item has/is this, do that

verification for each one of the line items, that's the reason that it works now. Let me know if I was clear enough

Shopify Developer
Hire me for theme customizations at ricardomsilvestre@outlook.com or Upwork
Was my answer helpful to you? Please like or mark as solution