Liquid Template Variables - line item

From Spiffy Stores Knowledge Base

A line item represents a single line in the shopping cart.

There is one line item for each distinct product variant being purchased, regardless of the quantity of that variant in the cart. It is important to include the line item's quantity whenever displaying the item to the user. Line items can be accessed from any theme or email template which makes a cart or order object available.

Line items used in the following theme and email templates:

  • cart.liquid
  • Order Confirmation
  • New Order Notification
  • New Order Notification (mobile)
  • Shipping confirmation
  • Shipping update
  • Additional Content & Scripts

Returns the unique internal id of the line item.

This is normally only for internal usage and is only available for order line items.


Returns a unique cart index number for the line item. This index number allows you to refer to a specific line item in the cart, even when there are other line items for the same variation.

This is only available for cart line items.

This variable is used in the cart.liquid template instead of that was previously used. The change is necessary as the cart now supports unique line items so that items with custom notes attached are added as unique line items. Obviously they all have the same value for, so this new index is used instead.


Returns the product variant for this line item.


Returns the product for this line_item.

For example, this code retrieves a line item's image:

{{ item.product.featured_image |  product_img_url | img_tag }}


Returns the title of this line item.

This is equal to the original product's title, for example, "Balloon Shirt". If the product has more than one variant, then the name of the variant will be appended to the title. So if the "Balloon Shirt" has two variants, "Medium" and "Large", then line_item.title will be "Balloon Shirt - Medium" or "Balloon Shirt - Large". If a "Yellow Flower Baseball Cap" product only has one variant called "Default" then its line_item.title would just be "Yellow Flower Baseball Cap".


Returns the title of this line item, without any additional variant option descriptions.

The additional variant option descriptions are available in line_item.extended_options.


Returns a hash of all variant option descriptions.

{% for option in line_item.extended_options %}
  <li>{{ option.first }}: {{ option.last }}</li>
{% endfor %}


Returns the single price of an item in this line item.


Returns the quantity of items are represented by this line item.


Returns the total weight of the items described by this line item in grams. You can format this for viewing by using the weight_with_unit filter.

Returns an array of properties that have been added to the line item when it was added to the cart, and are used to store custom information about that line item.

For more information, see the tutorial on Asking your customer for additional information.

As returns an array of elements, you will need to access each element of the array using a for loop.

  {% for property in %}
    <li>{{ property.first }}: {{ property.last }}</li>
  {% endfor %}

For example, you might have the following fields defined for your product:

Card Message: Thank you for all your help to set up my Spiffy Store.
Gift Wrapping: Yes


Returns the combined price of all the items in this line item. This is line_item.quantity times line_item.price less any discounts on the line item.

Returns the tax that is applicable for this line item.

Currently, tax is not calculated on a line item basis, so the value returned here is always zero.

Returns the total discount that has been applied to this line item. The discount is calculated from the Shopping Cart Discount rules.


Returns the SKU of the item's product variant.


Returns the value of the custom note associated with this line item.


Returns true if the line item is taxable and false if the line item is tax free.


Returns true if the line item was out of stock or partially out of stock at the time the order was placed. This flag will only be set if the item is configured to support inventory management and the setting allows the purchase of items even if they are out of stock.

{% if line_item.back_ordered %}This item is back ordered{% endif %}


Return the product page URL associated with this line item, including the variant parameter to enable direct linking to the selected variant.

{{ line_item.title | link_to: line_item.url }} =>

<a href="/products/cute-dog?variant=9876543">Cute Dog - Brown</a>


Return the image associated with the line item.

As a short-cut, we can apply the img_url filter directly to the line item, rather than using the line_item.image attribute.

{{ line_item.image | img_url: 'small' | img_tag }}

produces the same result as

{{ line_item | img_url: 'small' | img_tag }}