Shopify Custom Message In Order Confirmation Email Based On Product Title

0

I am trying to add a custom message in my Shopify order confirmation emails, based on any product titles. So if a customer orders any product that contains the title “Printed”, it should show some some specific content.

I have the below code, however if someone orders multiple products that contain the same title “Printed”, the content duplicates. I need it to not duplicate, but unsure how to code it.

{% for line in subtotal_line_items %}

{% if line.product.title %}

{% assign line_title2 = line.product.title %}

{% if line_title2 contains ‘Printed’ %}

CONTENT

{% else %}

CONTENT2

{% endif %}

{% endif %}

{% endfor %}

Can anyone help?

There is an App you can add to help you with that to avoid the coding issue and It will work perfectly according to the condition you add