Adding liquid to order confirmation for a specific product

We want a custom line of text (with a link) to go to customers who buy our Outdoor Garden Consult, which is for sale via the Buy Button on this page on our WordPress site:

https://theinspiredgarden.com/online-store/

I added the code below to our Order Confirmation notification and then made the purchase, but the text and link were not included in the confirmation email that I received. I also tried it with just product.title instead of line.product.title, but that didn’t work either.

{% if line.product.title == ‘Outdoor Garden Consult’ %}
Please schedule your Outdoor Garden Consult at Calendly - Customer Service</a](https://calendly.com/theinspiredgarden/">calendly.com/theinspiredgarden</a)>.
{% endif %}

What am I doing wrong? Screenshot below:

Hi @CharlieHanger
{{ line.product.title }} will work on {% for line as line.items %} loop.

Please add your code in for loop it will work.

@Dbuglabpvtltd - I’m not following you here. What code should I insert?

Hi @CharlieHanger

can you please share your code file

so I can check your code. And will give you answer accordingly.

It works with this:

  1. Find the Section Where Line Items are Listed: In your template, look for the loop that iterates over the line items in the order. It will look something like {% for line in subtotal_line_items %}. This part of the template is where each product in the order is displayed.

  2. Insert After Line Items Loop: Immediately after the loop that displays each product, paste the custom code snippet. This will make sure that the message about a specific product is displayed right above the item in the Order Summary.

Here’s the spot in your template where the custom code should be inserted:

!Your Existing Order Confirmation Code Displayed Here!

{% for line in subtotal_line_items %}

!Paste the custom code snippet here!
{% for line_item in order.line_items %}
{% if line_item.product.title == ‘Product Title 1’ or
line_item.product.title == ‘Product Title 2’ or
line_item.product.title == ‘Product Title 3’ %}

Your custom text goes here


{% endif %}
{% endfor %}

!The rest of your email template code continues below!


{% if line.image %}