The line_item object
A single line in a cart, a checkout, or an order. Each line item represents a distinct product variant.
In a theme, you might display line item information in two places:
- With your cart, using
cart.items
- In a customers/order template, using
order.items
line_item.discount_allocations
Anchor link to section titled "line_item.discount_allocations"Returns a list of all discount allocations containing the discounted amount and the reference to the parent discount application. line_item.discount_allocations
is available on line items in carts, checkouts, orders, and draft orders.
line_item.final_line_price
Anchor link to section titled "line_item.final_line_price"Returns the combined price of all the items in the line item. This is equal to line_item.final_price
times line_item.quantity
.
line_item.final_price
Anchor link to section titled "line_item.final_price"Returns the price of the line item including all line level discount amounts.
line_item.fulfillment
Anchor link to section titled "line_item.fulfillment"Returns the fulfillment of the line item.
line_item.fulfillment_service
Anchor link to section titled "line_item.fulfillment_service"Returns the fulfillment service associated with the line item's variant. Line items that have no fulfillment service will return manual
.
line_item.gift_card
Anchor link to section titled "line_item.gift_card"Returns true
if the line item's product is a gift card, or false
if it is not.
line_item.grams
Anchor link to section titled "line_item.grams"Returns the weight of the line item.
Use the weight_with_unit filter to format the weight.
line_item.id
Anchor link to section titled "line_item.id"Returns the line item ID.
The line item ID differs depending on the context:
cart.items
returns the ID of the line item's variant. This ID is not unique, and can be shared by multiple items of the same variant.checkout.line_items
returns a temporary unique hash generated for the checkout.order.line_items
returns a unique integer ID.
line_item.image
Anchor link to section titled "line_item.image"Returns the line item's image.
You can apply the image_url
filter directly to the line item instead of its image attribute. This will generate a working image URL for any object with an image attribute (variant, product, line item, collection), image object, or image src. This is useful for line items, since it will output the item's variant image or the product's featured image if no variant image exists.
In the example, note that the output is the same no matter if image_url
is used on line_item
or line_item.image
.
line_item.key
Anchor link to section titled "line_item.key"Returns the line item key, a unique identifier for the line item. The line item key is constructed from the ID of the line item's variant, and a hash of the line item's properties, even if the item has no additional properties.
line_item.line_level_discount_allocations
Anchor link to section titled "line_item.line_level_discount_allocations"Returns a list of line-specific discount allocations containing the discounted amount and the reference to the parent discount application. line_item.discount_allocations
is available on line items in carts, checkouts, orders, and draft orders.
line_item.line_level_total_discount
Anchor link to section titled "line_item.line_level_total_discount"Returns the total amount of all discounts applied to the line item specifically. This doesn't include discounts that are added to the cart.
line_item.message
Anchor link to section titled "line_item.message"Returns the discount message if a script has applied a discount to the line item.
This attribute only has a value if you are using the Script Editor app.
line_item.options_with_values
Anchor link to section titled "line_item.options_with_values"Returns an array of selected values from the item's product options.
Elements in line_item.options_with_values
can be displayed using a for
loop. Each option is a key-value pair with option.name
as the option and option.value
as the option value.
line_item.original_line_price
Anchor link to section titled "line_item.original_line_price"Returns the combined price of the quantity of items included in the line, before discounts were applied. This is equal to line_item.original_price
multiplied by line_item.quantity
.
line_item.original_price
Anchor link to section titled "line_item.original_price"Returns the original price of the line item before discounts were applied.
line_item.product
Anchor link to section titled "line_item.product"Returns the product of the line item.
line_item.product_id
Anchor link to section titled "line_item.product_id"Returns the ID of the line item's product.
line_item.properties
Anchor link to section titled "line_item.properties"Returns an array of custom information for an item that has been added to the cart.
You can capture line item properties on product pages to collect customization information for products, such as engraving text.
Line item properties can be captured on the product page with an input inside the product form. The input needs to have a name
attribute with the following value syntax:
For example, the following input would allow you to capture engraving text for a product:
You can output the properties by looping through each item in the line_item.properties
array:
line_item.quantity
Anchor link to section titled "line_item.quantity"Returns the quantity of the line item.
line_item.requires_shipping
Anchor link to section titled "line_item.requires_shipping"Returns true
if the variant of the line item requires shipping, or false
if it does not.
line_item.selling_plan_allocation
Anchor link to section titled "line_item.selling_plan_allocation"Returns a selling_plan_allocation
object when the line item contains a selling plan.
Availability of selling plan information
Anchor link to section titled "Availability of selling plan information"Selling plan group information is not recorded after a checkout is completed. As a result, when accessing a line item's selling_plan_allocation
from order.line_items
the following properties are not available:
selling_plan_group_id
selling_plan.group_id
selling_plan.options
Additionally, the following pricing properties are not available on a selling_plan_allocation
object when accessed from order.line_items
:
compare_at_price
price_adjustments
selling_plan.price_adjustments
line_item.sku
Anchor link to section titled "line_item.sku"Returns the SKU (stock keeping unit) of the line item's variant.
line_item.successfully_fulfilled_quantity
Anchor link to section titled "line_item.successfully_fulfilled_quantity"Returns the successfully fulfilled quantity of the line item.
line_item.taxable
Anchor link to section titled "line_item.taxable"Returns true
if taxes are charged on the line item's variant, or false
if they are not.
line_item.title
Anchor link to section titled "line_item.title"Returns the title of the line item. The line item title is a combination of the line item's product.title
and variant.title
, separated by a hyphen.
In most contexts, the line item title appears in the customer's preferred language. In the context of an order, the line item title appears in the language that the customer checked out in.
To output just the product title or variant title, you can access the title
of the respective variables.
Line item title history
Anchor link to section titled "Line item title history"When referencing line item, product, and variant titles in places like email notifications and the customers/order
template, the following changes might result in a different output than you expect:
- A product or variant being deleted
- A product or variant title being edited
When line_item.title
is referenced for an order, the line item title at the time of the order is returned. However, when line_item.product.title
and line_item.variant.title
are referenced, the current value for each title is returned.
For example, if you had a product titled Balloon Shirt
with a Medium
variant, and you edited the title to Awesome Balloon Shirt
after an order was placed, then line_item.title
would contain a different product title than line_item.product.title
:
Because of this, if you need to output product and variant titles separately, then you might want to extract them from line_item.title
to avoid customer confusion:
line_item.unit_price
Anchor link to section titled "line_item.unit_price"Returns the unit price of the line item. The price reflects any discounts that are applied to the line item.
line_item.unit_price_measurement
Anchor link to section titled "line_item.unit_price_measurement"Returns a unit_price_measurement object for the line item.
line_item.url
Anchor link to section titled "line_item.url"Returns the relative URL of the line item's variant. The relative URL does not include your store's root URL (mystore.myshopify.com
).
line_item.url_to_remove
Anchor link to section titled "line_item.url_to_remove"Returns a URL that can be used to remove the line item from the cart. This is only valid within the context of cart line items.
line_item.variant
Anchor link to section titled "line_item.variant"Returns the variant of the line item.
line_item.variant_id
Anchor link to section titled "line_item.variant_id"Returns the ID of the line item's variant.
line_item.vendor
Anchor link to section titled "line_item.vendor"Returns the vendor of the line item's product.