Adding product-specific logic to order confirmation?

Tara7
Shopify Partner
9 0 0

I'm trying to add certain text to the order notification email if the customer's order includes a specific product. It's really that simple: If customer orders X, show them this text. I've played around with some liquid code but I'm not getting it right. Can anybody help suggest what I need to include to make it work?

Thanks!

0 Likes
standoutd
Navigator
1135 0 128

Hi, Tara. Is the text for just one product or are there several? If multiple, do they share something the same, like type, vendor or tag? Does the text vary with different products? Happy to share some ideas with some more info!

 

http://www.StandoutDesigns.com ::: Solid Wood TV Furniture for Enthusiasts. Made in USA.
0 Likes
Tara7
Shopify Partner
9 0 0

Thanks so much for your response! The special text is for one product (a subscription) that has two variants (six-month subscription and twelve-month subscription). I'd want the text to appear when someone orders either variant, and the special text is the same regardless of variant.

This product has a unique "type" and I can give it a unique tag, too.

Does that help? Thanks again!

0 Likes
standoutd
Navigator
1135 0 128

Hi Tara. Maybe a programming whiz wants to jump in here but one idea I have is LINE ITEM PROPERTIES.

http://wiki.shopify.com/Line_Item_Properties#Implementation

In your case, you would actually want the INPUT field hidden and the default value set to your message. This approach would attach the message to the item and you could have it show in your order status page too, not just in the email. You might include logic to include the LINE ITEM PROPERTY in your product template for items of Type X (Subscriptions for example). Then if you add other subscriptions, you could have the same message go along with the item automatically.

To simply modify your order confirm template though it would look something like this

{% if line.title == 'YOUR PRODUCT NAME' %}

    Your message here.

{% endif %}

That would go in the loop in your email confirm template (Notifications section of Shopify 2 Admin). The loop looks like this:

{% for line in line_items %}

    {{ line.quantity }}x {{ line.title }} for {{ line.price | money }} each{% endfor %}

{% endfor %}

http://www.StandoutDesigns.com ::: Solid Wood TV Furniture for Enthusiasts. Made in USA.
0 Likes
Tara7
Shopify Partner
9 0 0

Wow, thanks! I opted for the latter suggestion, and I can't get the text to appear. I switched to "contains" because the titles are a little long (subscriptions - 6 months). Anything obviously wrong here?

{% for line in line_items %}
{% if line.title contains 'subscriptions' %}
Special text blah blah blah.
{% endif %}

{{ line.quantity }}x {{line.title }} for {{ line.price | money }} each
{% endfor %}

 

0 Likes
standoutd
Navigator
1135 0 128

Hmm. Could it be a case issue, as in "Subscriptions"? Also, you could use line_item.sku to test I would think.

 

http://www.StandoutDesigns.com ::: Solid Wood TV Furniture for Enthusiasts. Made in USA.
0 Likes
Tara7
Shopify Partner
9 0 0

A-HA! The "contains" tag is indeed case-sensitive.

You are my hero today. Thank you ever so much for your generous help and skills!

0 Likes
standoutd
Navigator
1135 0 128

You are welcome. Truth be told, I got lucky. :-)

http://www.StandoutDesigns.com ::: Solid Wood TV Furniture for Enthusiasts. Made in USA.
0 Likes
Tara7
Shopify Partner
9 0 0

I won't tell.

0 Likes
Felicia_Raffael
New Member
1 0 0

This is super helpful! Thank you.

We are trying to setup a message for our leather cap OR everything else (the title would contain either "tank top", "t-shirt" or "shirt").

Is there any way to set only one condition for the title to contain either one of those words? I have never done this before, my knowledge of coding is really basic, so I want to make sure I am not messing it up. 

0 Likes