line_ item
A line in a cart, checkout, or order. Each line item represents a product variant.
Properties
- discount_
allocations array of discount_allocation The discount allocations that apply to the line item.
CautionNot applicable for item component as discounts are applied to the parent line item.
An informational error message about the status of the line item in the buyer's chosen language.
NoteThis field is applicable for cart line item only and currently available for shops using Checkout Extensibility.
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
multiplied by
. 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.
TipUse money filters to output a formatted 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.
TipUse money filters to output a formatted price.
- fulfillment
The fulfillment of the line item.
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. Returnsfalse
if not.The weight of the line item in the store's default weight unit.
TipUse this property with the
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:
Context Value cart.items
The ID of the line item's variant.
This ID isn't unique, and can be shared by multiple items with the same variant.A temporary unique hash generated for the checkout. A 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
The components of a line item.
NoteThis 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.
- line_
level_ discount_ allocations array of discount_allocation The discount allocations that apply directly to the line item.
CautionNot applicable for item component as discounts are applied to the parent line item.
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.
TipUse 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 discounts Value 0 nil
1 The title of the discount. More than 1 A Shopify generated string noting how many discounts have been applied. - options_
with_ values The name and value pairs for each option of the variant associated with the line item.
NoteThe array is never empty because variants with no options still have a default option. Because of this, you should use
to check whether there's any information to output.
ExampleOutput 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 %}{% 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 %}
{ "cart": { "items": [ { "product": { "has_only_default_variant": true }, "title": "Whole bloodroot" }, { "product": { "has_only_default_variant": true }, "title": "Viper venom" } ] } }
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>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
multiplied by
. 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.
TipUse money filters to output a formatted 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.
TipUse money filters to output a formatted price.
- 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:
TipTo learn about how to display captured properties, refer to Display line item properties.
ExampleCapture line item properties in the product formTo 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 %}TipYou can add an underscore to the beginning of a property name to hide it from customers at checkout. For example,
.
Returns
true
if the variant associated with the line item requires shipping. Returnsfalse
if not.- 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:
The number of items from the line item that have been successfully fulfilled.
Returns
true
if taxes should be charged on the line item. Returnsfalse
if not.The title of the line item. The title is a combination of
and
, 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
is referenced for an order, the line item title at the time of the order is returned. However, when
and
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.
NoteUnit prices are available only to stores located in the European Union or Switzerland.
TipUse the
filter with this property and the
property to output a formatted unit price with measurement.
To learn about how to display unit prices in your theme, refer to Unit pricing.
- unit_
price_ measurement The unit price measurement of the line item.
NoteUnit 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.
TipUse the
filter with the
property and this property to output a formatted unit price with measurement.
A URL to remove the line item from the cart.
TipTo learn more about how to use this property in your theme, refer to Remove line items from the cart.
Deprecated Properties
The discounts applied to the line item.
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
multiplied by
. 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.
TipUse money filters to output a formatted price.
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.
TipUse money filters to output a formatted price.
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.
TipUse money filters to output a formatted amount.
{
"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"
}