Adding liquid to order confirmation for a specific product

Topic summary

A user wants to add custom text with a link to order confirmation emails for customers purchasing a specific product (“Outdoor Garden Consult”) sold through a Shopify Buy Button on their WordPress site.

Initial Problem:

  • The user added Liquid code to the Order Confirmation notification template, but it didn’t appear in test emails
  • Tried both line.product.title and product.title without success

Solution Provided:
The code must be placed within the existing line items loop in the email template:

  1. Locate the {% for line in subtotal_line_items %} loop in the template
  2. Insert the conditional code inside this loop to check if the product title matches “Outdoor Garden Consult”
  3. The custom message will then display in the Order Summary section

Key Technical Point:
The variable line.product.title only works within a for loop context. The original code failed because it wasn’t placed inside the proper loop structure where line items are iterated.

A community member provided the exact template structure showing where to insert the custom code snippet between the line items loop and the rest of the email template.

Summarized with AI on November 12. AI used: claude-sonnet-4-5-20250929.

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 %}