Currently in my shopify code I can use a line item input like so:
line_item.variant.title
This will output the following:
Snapback / One Size Fits All / Camo
What I’m trying to do is to break up each one into it’s own line. So I can get this back:
Snapback
One Size Fits All
Camo
The challenge is that there are several products with different variants. Some contain the string “7/9” so I wouldn’t be able to use “/” as a delimiter. Any suggestions?
2
Answers
The variant title is generated based on the variant options.
So if you like to show the different options you just call the options instead of the title.
Example:
Refer to the docs here: https://help.shopify.com/en/themes/liquid/objects/variant#variant-option1
I found this one is a better solution to set this dynamically:
As by default, we are getting
/
in the value ofline.variant.title
. So we need to split this first So that we can get individual option values. and because there is no feasible object to get option label so we need to use theline.product.options_with_values
in a loop and iterate and set label with value as in the above code.So, just use this code in your order confirmation email and you will get the format in the email as follow. Here Embroidery as yes and no. and Border as Zigzag and Simple are the options for product variants.