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:
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.
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.
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!