Skip to main content

line_item

A line in a cart, checkout, or order. Each line item represents a product variant.

Properties

Anchor to
discount_allocations

The discount allocations that apply to the line item.

Caution

Not applicable for item component as discounts are applied to the parent line item.

Anchor to
error_message

An informational error message about the status of the line item in the buyer's chosen language.

Note

This field is applicable for cart line item only and currently available for shops using Checkout Extensibility.

Anchor to
final_line_price

The combined price, in the currency's subunit, of all of the items in the line item. This includes any line-level discounts.

The value is equal to line_item.final_price multiplied by line_item.quantity. It's output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted price.

Anchor to
final_price

The price of the line item in the currency's subunit. This includes any line-level discounts.

The value is output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted price.

The fulfillment of the line item.

Anchor to
fulfillment_service

The fulfillment service for the vartiant associated with the line item. If there's no fulfillment service, then manual is returned.

Returns true if the product associated with the line item is a gift card. Returns false if not.

The weight of the line item in the store's default weight unit.

Tip

Use this property with the weight_with_unit filter to format the weight.

The ID of the line item.

The ID differs depending on the context. The following table outlines the possible contexts and their associated values:

ContextValue
cart.itemsThe ID of the line item's variant.

This ID isn't unique, and can be shared by multiple items with the same variant.
checkout.line_itemsA temporary unique hash generated for the checkout.
order.line_itemsA unique integer ID.

The image of the line item.

The image can come from one of the following sources:

  • The image of the variant associated with the line item
  • The featured image of the product associated with the line item, if there's no variant image
Anchor to
item_components
array of line_item

The components of a line item.

Note

This field is applicable for cart line item only.

The key of the line item.

Line item keys are unique identifiers that consist of the following components separated by a colon:

  • The ID of the variant associated with the line item
  • A hash of unique characteristics of the line item.

Note: Line item keys are not stable identifiers. The line item key will change as characteristics of the line item change. This includes, but is not limited to, properties and discount applications.

Anchor to
line_level_discount_allocations

The discount allocations that apply directly to the line item.

Caution

Not applicable for item component as discounts are applied to the parent line item.

Anchor to
line_level_total_discount

The total amount of any discounts applied to the line item in the currency's subunit.

The value is output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted amount.

Information about the discounts that have affected the line item.

The following table outlines what's returned depending on the number of discounts affecting the line item:

Number of discountsValue
0nil
1The title of the discount.
More than 1A Shopify generated string noting how many discounts have been applied.
Anchor to
options_with_values

The name and value pairs for each option of the variant associated with the line item.

Note

The array is never empty because variants with no options still have a default option. Because of this, you should use line_item.product.has_only_default_variant to check whether there's any information to output.

Example
Output the option values
{% for item in cart.items %}
<div class="cart__item">
<p class="cart__item-title">
{{ item.title }}
</p>

{%- unless item.product.has_only_default_variant %}
<ul>
{% for option in item.options_with_values -%}
<li>{{ option.name }}: {{ option.value }}</li>
{%- endfor %}
</ul>
{% endunless %}
</div>
{% endfor %}

Output

<div class="cart__item">
<p class="cart__item-title">
Whole bloodroot
</p>
</div>

<div class="cart__item">
<p class="cart__item-title">
Viper venom
</p>
</div>
Anchor to
original_line_price

The combined price of all of the items in a line item in the currency's subunit, before any discounts have been applied.

The value is equal to line_item.original_price multiplied by line_item.quantity. It's output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted price.

Anchor to
original_price

The price of the line item in the currency's subunit, before discounts have been applied.

The value is output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted price.

The product associated with the line item.

The ID of the line item's product.

Anchor to
properties

The properties of the line item.

You can add, or allow customers to add, custom information to a line item with line item properties.

Line item properties consist of a name and value pair. They can be captured with the following methods:

Tip

To learn about how to display captured properties, refer to Display line item properties.

Example
Capture line item properties in the product form

To capture line item properties inside the product form, you need to include an input, for each property. Each input needs a unique name attribute. Use the following format:

name="properties[property-name]"

The value of the input is captured as the value of the property.

For example, you can use the following code to capture custom engraving text for a product:

{% form 'product', product %}
...
<label for="engravingText">Engraving<label>
<input type="text" id="engravingText" name="properties[Engraving]">
...
{% endform %}

Tip

You can add an underscore to the beginning of a property name to hide it from customers at checkout. For example, properties[_hiddenPropertyName].


The quantity of the line item.

Anchor to
requires_shipping

Returns true if the variant associated with the line item requires shipping. Returns false if not.

Anchor to
selling_plan_allocation

The selling plan allocation of the line item. If the line item doesn't have a selling plan allocation, then nil is returned.

Availability of selling plan information

The following properties aren't available when referencing selling plan information through an order's line items:

Tip

If you need to show selling plan information post-purchase, then you should use selling_plan.name.

The sku of the variant associated with the line item.

Anchor to
successfully_fulfilled_quantity

The number of items from the line item that have been successfully fulfilled.

Anchor to
tax_lines
array of tax_line

The tax lines for the line item.

Returns true if taxes should be charged on the line item. Returns false if not.

The title of the line item. The title is a combination of line_item.product.title and line_item.variant.title, separated by a hyphen.

In most contexts, the line item title appears in the customer's preferred language. However, in the context of an order, the line item title appears in the language that the customer checked out in. The title can receive an override value from the Cart Transform API. Overrides take precedence over translations.

Line item title history

When referencing line item, product, and variant titles in the context of an order, 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.

The unit price of the line item in the currency's subunit.

The price reflects any discounts that are applied to the line item. The value is output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Note

Unit prices are available only to stores located in the European Union or Switzerland.

Tip

Use the unit_price_with_measurement filter with this property and the line_item.unit_price_measurement property to output a formatted unit price with measurement.

To learn about how to display unit prices in your theme, refer to Unit pricing.

Anchor to
unit_price_measurement

The unit price measurement of the line item.

Note

Unit prices are available only to stores located in the European Union or Switzerland.

To learn about how to display unit prices in your theme, refer to Unit pricing.

Tip

Use the unit_price_with_measurement filter with the line_item.unit_price property and this property to output a formatted unit price with measurement.

The relative URL of the variant associated with the line item.

Anchor to
url_to_remove

A URL to remove the line item from the cart.

Tip

To learn more about how to use this property in your theme, refer to Remove line items from the cart.

The variant associated with the line item.

The ID of the line item's variant.

The vendor of the variant associated with the line item.

Deprecated Properties

Anchor to
discounts
array of discount
Deprecated

The discounts applied to the line item.

Deprecated

Deprecated because not all discount types and details are available.

The line_item.discounts property has been replaced by line_item.discount_allocations.

Anchor to
line_price
Deprecated

The combined price, in the currency's subunit, of all of the items in a line item. This includes any discounts from Shopify Scripts.

The value is equal to line_item.price multiplied by line_item.quantity. It's output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted price.

Deprecated

Deprecated because discounts from automatic discounts and discount codes aren't included.

The line_item.line_price property has been replaced by line_item.final_line_price.

Anchor to
price
Deprecated

The price of the line item in the currency's subunit. This includes any discounts from Shopify Scripts.

The value is output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted price.

Deprecated

Deprecated because discounts from automatic discounts and discount codes aren't included.

The line_item.price property has been replaced by line_item.final_price.

Anchor to
total_discount
Deprecated

The total amount, in the currency's subunit, of any discounts applied to the line item by Shopify Scripts.

The value is output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted amount.

Deprecated

Deprecated because discounts from automatic discounts and discount codes aren't included.

The line_item.total_discount property has been replaced by line_item.line_level_total_discount.

{
"discount_allocations": [],
"discounts": [],
"error_message": "",
"final_line_price": "74.97",
"final_price": "24.99",
"fulfillment": {},
"fulfillment_service": "manual",
"gift_card": false,
"grams": 0,
"id": 10974183882817,
"image": {},
"item_components": null,
"key": 10974183882817,
"line_level_discount_allocations": [],
"line_level_total_discount": "0.00",
"line_price": "74.97",
"message": "",
"options_with_values": [
{
"name": "Title",
"value": "Default Title"
}
],
"original_line_price": "74.97",
"original_price": "24.99",
"price": "24.99",
"product": {},
"product_id": 6792596455489,
"properties": {},
"quantity": 3,
"requires_shipping": true,
"selling_plan_allocation": null,
"sku": "",
"successfully_fulfilled_quantity": 2,
"tax_lines": [],
"taxable": true,
"title": "Bloodroot (whole)",
"total_discount": "0.00",
"unit_price": "49.98",
"unit_price_measurement": {
"measured_type": "weight",
"quantity_value": "500.0",
"quantity_unit": "g",
"reference_value": 1,
"reference_unit": "kg"
},
"url": {},
"url_to_remove": null,
"variant": {},
"variant_id": 39888235757633,
"vendor": "Clover's Apothecary"
}
Was this section helpful?