Options on cart page

If you want to list the selected options on the cart page, follow the steps below.

All entered option values are stored on the line_item.properties.

Automatic

Most themes will automatically list all the line item properties on the cart page.

Manual

If your theme does not show the options automatically, you can use the following code to show them on your cart page.

In your cart template, look for the part where each line item is iterated:

{%- for item in cart.items -%}

Inside the loop, add the following code at the location where you want to show the options:

{%- for p in item.properties -%}
       {%- if p.first.first == '_' -%}{% continue %}{%- endif -%}
        <div><b>{{ p.first }}: </b><span>{{ p.last }}</span></div>
{%- endfor -%}

This code will show each option on a new line.

Keeping line breaks inside a value

An option that accepts several lines of text, such as a multiline text option or a text editor, stores the line breaks the customer typed. HTML ignores raw line breaks, so by default the cart page shows the whole entry on one line even though the data is intact. The original formatting is still on the order.

To render it as the customer entered it, either preserve the whitespace with CSS:

<div style="white-space: pre-wrap;">{{ p.last }}</div>

or convert the line breaks to <br>  tags in Liquid:

{{ p.last | newline_to_br }}

Both go in the cart template, in the loop over item.properties  shown above. The CSS can also be put on the theme's existing cart property element in the stylesheet instead of inline.

The same applies anywhere else the property is printed. For the order confirmation email, apply the same filter or inline style in Settings > Notifications > Order confirmation.

Shopify controls the checkout page layout, so neither change affects how the text appears there.

For very long entries, limit the displayed length (for example to the first 100 characters) to keep the cart layout readable.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.