Line Item

From Shopify Wiki

Jump to: navigation, search

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.

You are most likely to see line items used in the following theme and email templates:


Contents

line_item.id

Returns the id of this line item

line_item.variant

Returns the product variant of this line item.

line_item.product

Returns the product of this line_item.

Example for getting 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, e.g. "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 Baloon 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.line_price

Returns the combined price of all the items in this line_item. This is quantity times line_item.price.

line_item.tax

Returns the tax that is applicable for this line_item.

line_item.quantity

Returns how many items are represented by this line_item.

line_item.grams

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

line_item.sku

Returns the SKU of the item's product variant.

Personal tools