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
Contents
line_item.id
Returns the unique internal id of the line item.
This is normally only for internal usage.
line_item.variant
Returns the product variant for this line item.
line_item.product
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 }}
line_item.title
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".
line_item.price
Returns the single price of an item in this line item.
line_item.quantity
Returns the quantity of items are represented by this line item.
line_item.grams
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.
line_item.line_price
Returns the combined price of all the items in this line item. This is line_item.quantity times line_item.price.
line_item.tax
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.
line_item.sku
Returns the SKU of the item's product variant.