The liquid to add the product variant title into a Shopify Notification Email

Solved
Highlighted
Tourist
13 0 2

 line variant code.png

 

Hmm. Yeah, so I only get the product title when I insert this code

1 Like
Highlighted
Shopify Partner
77 8 19

Right! Sorry about that! I made a small mistake in the code that I gave you. You can keep it all the same, just one small change.

 

The very first part of the code that I told you is this:

 

{% if line.product.tags.contains 'Rings' %}

It should actually be like this:

 

{% if line.product.tags contains 'Rings' %}

Essentially just swapping that one full stop to a space. Hopefully this will fix it for you!

 

Let me know how you go,

Josh

Joshua Sarros - Freelance Web Developer from Melbourne, Australia
joshuasarros@gmail.com
0 Likes
Highlighted
Tourist
13 0 2

It worked! Thank you so much.

 

I did try to inject the same code into my shipping confirmation email. It didn't quite work. The product title just disappeared altogether. Would the code have to be different here?

 

I did notice between the order and shipping confirmation emails there is a difference between the coding for the product title. In the order confirmation, I took out the code ' line.title' out and replaced it with your code.

 

If I go to the coding for the product title in the shipping confirmation email, the code is as follows 'line.line_item.title' instead of 'line.title'

0 Likes
Highlighted
Shopify Partner
77 8 19

Awesome! Glad that one worked.

 

For this other template, it's a bit hard for me to say for sure what the code will need to be, but looking at an example template that I have (hopefully it's similar) it looks as though you can use the same code that I have previously sent. Would you be able to send me a chunk of the code around the part that you want to change so that I can see if it matches up with what I am looking at?

Joshua Sarros - Freelance Web Developer from Melbourne, Australia
joshuasarros@gmail.com
1 Like
Highlighted
Tourist
13 0 2

Yeah, it didn't work when I tried. The product title in the shipping confirmation email just disappeared altogether. Attached are photos of the email's code prior to inserting any new code. On the 5th photo is the relevant code that I need to modify. It is highlighted yellow.

 

pg. 1 of code.pngpg. 2 of code.pngpg. 3 of code.pngpg. 4 of code.pngpg. 5 of code.png

0 Likes
Highlighted
Shopify Partner
77 8 19

This is an accepted solution.

Thanks for sending all that through! I have been reading over it and trying to work out a few things because it looks like there's some inconsistency in the code. Was that code ever updated at all?

 

Anyway, what I think you might be able to do use try this code if you don't mind:

{% if line.line_item.product.tags contains 'Rings' %}{{ line.line_item.product.title }} - Ring Size {{ line.line_item.variant.title }}{% else %}{{ line.line_item.title }}{% endif %}

Looking at your screenshots, I made a few changes and hopefully this will work!

 

Let me know :)

Joshua Sarros - Freelance Web Developer from Melbourne, Australia
joshuasarros@gmail.com
1 Like
Highlighted
Tourist
13 0 2

Hey Joshua, it worked! Thank you very much. And yeah I modified the code. The email was made in the app, 'Klaviyo', in liquid, and exported into Shopify. Thank you so much for your help throughout this process! 

1 Like
Shopify Partner
77 8 19

My pleasure! Glad it worked in the end :)

 

If you ever need a hand in the future feel free to contact me!

Joshua Sarros - Freelance Web Developer from Melbourne, Australia
joshuasarros@gmail.com
1 Like
Highlighted
Tourist
13 0 2

Hey Joshua. Okay back to the drawing board. Instead of appending 'Ring Size - X'  at the end of the product title of any ring, I need the variant to have its own row. To quote my boss: 

 

What I'd been aiming for was including the variant information for all variants similar to how the quantity is displayed (ie. just a name: value pair below the title) so this is extensible beyond the current scenario. Eg. if we had the crystal items with a "color" variant it would also work

So if there is a variant, have it show up under the product title like quantity does. Could you help with that? There is some if then logic in there that is a bit out of my reach

0 Likes
Highlighted
Shopify Partner
77 8 19

Hey ConnorHolliday,

Hope you're well!

 

That should be possible for sure. Considering the work involved I won't be able to help you with this here, hopefully someone will be able to help you out. Otherwise feel free to email me and I'd be happy to talk it over with you some more.

 

Josh.

Joshua Sarros - Freelance Web Developer from Melbourne, Australia
joshuasarros@gmail.com
0 Likes