Ad

Shopify Line Item Variants In Separate Lines

- 1 answer

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?

Ad

Answer

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:

{{ variant.option1 }}<br/>
{{ variant.option2 }}<br/>
{{ variant.option3 }}

Refer to the docs here: https://help.shopify.com/en/themes/liquid/objects/variant#variant-option1

Ad
source: stackoverflow.com
Ad