---
title: Cart Line Item API
description: >-
The Cart Line Item API provides read-only access to a specific line item in
the cart. Use this API to get line item details like product information,
pricing, discounts, and custom properties. This allows you to build features
that respond to the specific item a customer is viewing or interacting with.
api_version: 2025-10
api_name: pos-ui-extensions
source_url:
html: >-
https://shopify.dev/docs/api/pos-ui-extensions/latest/target-apis/contextual-apis/cart-line-item-api
md: >-
https://shopify.dev/docs/api/pos-ui-extensions/latest/target-apis/contextual-apis/cart-line-item-api.md
---
# Cart Line Item API
The Cart Line Item API provides read-only access to a specific line item in the cart. Use this API to get line item details like product information, pricing, discounts, and custom properties. This allows you to build features that respond to the specific item a customer is viewing or interacting with.
#### Use cases
* **Line item details:** Display detailed information including product details, pricing, and quantities.
* **Item-specific actions:** Implement actions based on product type, vendor, or selling plan requirements.
* **Contextual UI:** Create interfaces that adapt based on line item characteristics.
* **Discounts and properties:** Access discounts, properties, and selling plans for specialized interfaces.
Support
Targets (2)
### Supported targets
* [pos.cart.line-item-details.action.menu-item.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/cart-details#cart-details-action-menu-item-)
* [pos.cart.line-item-details.action.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/cart-details#cart-details-action-modal-)
## CartLineItemApi
The `CartLineItemApi` object provides access to the current line item. Access this property through `api.cartLineItem` to interact with the current line item context.
* cartLineItem
LineItem
required
The selected line item in the merchant's current cart. Provides complete line item data including product information, pricing, discounts, properties, and metadata. Use for displaying item details and implementing item-specific functionality.
### LineItem
Represents an individual item in the shopping cart. Contains product information, pricing, quantity, discounts, and customization details for a single cart entry.
* attributedUserId
The staff member 'ID' attributed to this line item. Returns 'undefined' if no staff attribution is set. Use for commission tracking and performance analytics.
```ts
number
```
* components
Bundle components for this line item. Only present for \[product bundles]\(/docs/apps/build/product-merchandising/bundles). Each component represents an individual item within the bundle with its own tax information.
```ts
LineItemComponent[]
```
* discountAllocations
An array of discount allocations applied to this line item, providing detailed breakdown of how discounts are distributed. Returns 'undefined' if no allocations exist. Use for enhanced discount tracking and reporting.
```ts
DiscountAllocation[]
```
* discounts
An array of discounts applied to this line item. Empty array if no discounts are active. Use for displaying line item savings and discount details.
```ts
Discount[]
```
* hasSellingPlanGroups
Determines whether this line item has selling plan groups (subscription options) available. Returns 'undefined' if selling plan information is unavailable. Use for displaying subscription options.
```ts
boolean
```
* isGiftCard
Determines whether this line item is a gift card. Gift cards have special handling requirements and business logic. Use for implementing gift card-specific workflows.
```ts
boolean
```
* price
The unit price of the line item. Returns 'undefined' for custom sales without set prices. Use for pricing calculations and displays.
```ts
number
```
* productId
The product 'ID' this line item represents. Returns 'undefined' for custom sales or non-product items. Use for product-specific operations and linking to product details.
```ts
number
```
* properties
The custom key-value properties attached to this line item. Empty object if no properties are set. Use for metadata, customization options, or integration data.
```ts
{ [key: string]: string; }
```
* quantity
The quantity of this item in the cart. Always a positive integer. Use for quantity displays, calculations, and inventory management.
```ts
number
```
* requiresSellingPlan
Determines whether this line item requires a selling plan (subscription) to be purchased. Returns 'undefined' if selling plan information is unavailable. Use for implementing subscription-based product handling.
```ts
boolean
```
* sellingPlan
The currently selected selling plan for this line item. Returns 'undefined' if no selling plan is applied. Contains selling plan details including 'ID', name, and delivery intervals. Use for subscription management and recurring purchase functionality.
```ts
SellingPlan
```
* sku
The Stock Keeping Unit (SKU) identifier for this line item. Returns 'undefined' if no SKU is configured. Use for inventory tracking and product identification.
```ts
string
```
* taxable
Determines whether this line item is subject to tax calculations. Use for tax computation, compliance, and pricing displays.
```ts
boolean
```
* taxLines
An array of tax lines applied to this line item, containing tax amounts and rates. Use for detailed tax reporting and compliance.
```ts
TaxLine[]
```
* title
The display title of the line item. Returns 'undefined' for items without titles. Use for customer-facing displays and cart item identification.
```ts
string
```
* uuid
The unique identifier for this line item within the cart. Use for line item-specific operations like updates, removals, or property modifications.
```ts
string
```
* variantId
The product variant 'ID' this line item represents. Returns 'undefined' for custom sales or non-variant items. Use for variant-specific operations and product details.
```ts
number
```
* vendor
The vendor or brand name for this line item. Returns 'undefined' if no vendor is set. Use for vendor-specific displays and organization.
```ts
string
```
```ts
export interface LineItem {
/**
* The unique identifier for this line item within the cart. Use for line item-specific operations like updates, removals, or property modifications.
*/
uuid: string;
/**
* The unit price of the line item. Returns 'undefined' for custom sales without set prices. Use for pricing calculations and displays.
*/
price?: number;
/**
* The quantity of this item in the cart. Always a positive integer. Use for quantity displays, calculations, and inventory management.
*/
quantity: number;
/**
* The display title of the line item. Returns 'undefined' for items without titles. Use for customer-facing displays and cart item identification.
*/
title?: string;
/**
* The product variant 'ID' this line item represents. Returns 'undefined' for custom sales or non-variant items. Use for variant-specific operations and product details.
*/
variantId?: number;
/**
* The product 'ID' this line item represents. Returns 'undefined' for custom sales or non-product items. Use for product-specific operations and linking to product details.
*/
productId?: number;
/**
* An array of discounts applied to this line item. Empty array if no discounts are active. Use for displaying line item savings and discount details.
*/
discounts: Discount[];
/**
* An array of discount allocations applied to this line item, providing detailed breakdown of how discounts are distributed. Returns 'undefined' if no allocations exist. Use for enhanced discount tracking and reporting.
*/
discountAllocations?: DiscountAllocation[];
/**
* Determines whether this line item is subject to tax calculations. Use for tax computation, compliance, and pricing displays.
*/
taxable: boolean;
/**
* An array of tax lines applied to this line item, containing tax amounts and rates. Use for detailed tax reporting and compliance.
*/
taxLines: TaxLine[];
/**
* The Stock Keeping Unit (SKU) identifier for this line item. Returns 'undefined' if no SKU is configured. Use for inventory tracking and product identification.
*/
sku?: string;
/**
* The vendor or brand name for this line item. Returns 'undefined' if no vendor is set. Use for vendor-specific displays and organization.
*/
vendor?: string;
/**
* The custom key-value properties attached to this line item. Empty object if no properties are set. Use for metadata, customization options, or integration data.
*/
properties: {[key: string]: string};
/**
* Determines whether this line item is a gift card. Gift cards have special handling requirements and business logic. Use for implementing gift card-specific workflows.
*/
isGiftCard: boolean;
/**
* The staff member 'ID' attributed to this line item. Returns 'undefined' if no staff attribution is set. Use for commission tracking and performance analytics.
*/
attributedUserId?: number;
/**
* Determines whether this line item requires a selling plan (subscription) to be purchased. Returns 'undefined' if selling plan information is unavailable. Use for implementing subscription-based product handling.
*/
requiresSellingPlan?: boolean;
/**
* Determines whether this line item has selling plan groups (subscription options) available. Returns 'undefined' if selling plan information is unavailable. Use for displaying subscription options.
*/
hasSellingPlanGroups?: boolean;
/**
* The currently selected selling plan for this line item. Returns 'undefined' if no selling plan is applied. Contains selling plan details including 'ID', name, and delivery intervals. Use for subscription management and recurring purchase functionality.
*/
sellingPlan?: SellingPlan;
/**
* Bundle components for this line item. Only present for [product bundles](/docs/apps/build/product-merchandising/bundles). Each component represents an individual item within the bundle with its own tax information.
*/
components?: LineItemComponent[];
}
```
### LineItemComponent
Represents a component of a \[product bundle]\(/docs/apps/build/product-merchandising/bundles) line item. Bundle components contain the individual items that make up a bundle, each with their own pricing and tax information.
* price
The price for the custom sale item as currency string. Must be a valid positive amount. Use for non-catalog items and custom pricing.
```ts
number
```
* productId
The unique numeric identifier for the product this component represents, if applicable.
```ts
number
```
* quantity
The quantity of the custom sale item. Must be a positive integer. Use for quantity-based pricing and inventory management.
```ts
number
```
* taxable
Determines whether the custom sale item is taxable. Set to \`true\` to apply tax calculations, \`false\` to exempt from taxes.
```ts
boolean
```
* taxLines
An array of tax lines applied to this component.
```ts
TaxLine[]
```
* title
The display name for the custom sale item. Appears on receipts and in cart displays. Should be descriptive and customer-friendly.
```ts
string
```
* variantId
The unique numeric identifier for the product variant this component represents, if applicable.
```ts
number
```
```ts
export interface LineItemComponent {
/**
* The display name for the custom sale item. Appears on receipts and in cart displays. Should be descriptive and customer-friendly.
*/
title?: string;
/**
* The quantity of the custom sale item. Must be a positive integer. Use for quantity-based pricing and inventory management.
*/
quantity: number;
/**
* The price for the custom sale item as currency string. Must be a valid positive amount. Use for non-catalog items and custom pricing.
*/
price?: number;
/**
* Determines whether the custom sale item is taxable. Set to `true` to apply tax calculations, `false` to exempt from taxes.
*/
taxable: boolean;
/**
* An array of tax lines applied to this component.
*/
taxLines: TaxLine[];
/**
* The unique numeric identifier for the product variant this component represents, if applicable.
*/
variantId?: number;
/**
* The unique numeric identifier for the product this component represents, if applicable.
*/
productId?: number;
}
```
### TaxLine
Represents a tax line applied to an item or transaction.
* enabled
Whether this tax is currently enabled.
```ts
boolean
```
* price
The tax amount as a Money object.
```ts
Money
```
* rate
The tax rate as a decimal number.
```ts
number
```
* rateRange
The range of tax rates if applicable.
```ts
{ min: number; max: number; }
```
* title
The title or name of the tax.
```ts
string
```
* uuid
The unique identifier for this tax line.
```ts
string
```
```ts
export interface TaxLine {
/**
* The title or name of the tax.
*/
title: string;
/**
* The tax amount as a Money object.
*/
price: Money;
/**
* The tax rate as a decimal number.
*/
rate: number;
/**
* The unique identifier for this tax line.
*/
uuid?: string;
/**
* The range of tax rates if applicable.
*/
rateRange?: {min: number; max: number};
/**
* Whether this tax is currently enabled.
*/
enabled?: boolean;
}
```
### Money
Represents a monetary amount with currency information.
* amount
The monetary amount as a number.
```ts
number
```
* currency
The \[ISO 4217]\(https://en.wikipedia.org/wiki/ISO\_4217) currency code associated with the location currently active on POS.
```ts
string
```
```ts
export interface Money {
/**
* The monetary amount as a number.
*/
amount: number;
/**
* The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code associated with the location currently active on POS.
*/
currency: string;
}
```
### DiscountAllocation
Represents the allocation of a discount to a specific line item.
* allocatedAmount
The amount of discount allocated.
```ts
MoneyV2
```
```ts
export interface DiscountAllocation {
/**
* The amount of discount allocated.
*/
allocatedAmount: MoneyV2;
}
```
### MoneyV2
Represents a monetary amount as a string with explicit currency code.
* amount
The monetary amount as a string.
```ts
string
```
* currencyCode
The ISO currency code (for example, USD, CAD).
```ts
string
```
```ts
export interface MoneyV2 {
/**
* The monetary amount as a string.
*/
amount: string;
/**
* The ISO currency code (for example, USD, CAD).
*/
currencyCode: string;
}
```
### Discount
Represents a discount applied to a cart or transaction, including amount and description.
* amount
The discount value to apply. For \`'Percentage'\` type, this represents the percentage value (For example, "10" for 10% off). For \`'FixedAmount'\` type, this represents the fixed monetary amount to deduct from the line item price. Commonly used for discount calculations and displaying the discount value to merchants.
```ts
number
```
* currency
The \[ISO 4217]\(https://en.wikipedia.org/wiki/ISO\_4217) currency code associated with the location currently active on POS.
```ts
string
```
* discountDescription
A human-readable description of the discount shown to merchants and customers. This typically includes the discount name, promotion details, or discount code (for example, "SUMMER2024", "10% off entire order", "Buy 2 Get 1 Free"). Returns \`undefined\` when no description is provided.
```ts
string
```
* type
The \[discount type]\(https://help.shopify.com/en/manual/discounts/discount-types) applied to this line item. Can be either \`'Percentage'\` for percentage-based discounts or \`'FixedAmount'\` for fixed monetary amount discounts. This determines how the discount amount is calculated and displayed.
```ts
string
```
```ts
export interface Discount {
/**
* The discount value to apply. For `'Percentage'` type, this represents the percentage value (For example, "10" for 10% off). For `'FixedAmount'` type, this represents the fixed monetary amount to deduct from the line item price. Commonly used for discount calculations and displaying the discount value to merchants.
*/
amount: number;
/**
* The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code associated with the location currently active on POS.
*/
currency?: string;
/**
* A human-readable description of the discount shown to merchants and customers. This typically includes the discount name, promotion details, or discount code (for example, "SUMMER2024", "10% off entire order", "Buy 2 Get 1 Free"). Returns `undefined` when no description is provided.
*/
discountDescription?: string;
/**
* The [discount type](https://help.shopify.com/en/manual/discounts/discount-types) applied to this line item. Can be either `'Percentage'` for percentage-based discounts or `'FixedAmount'` for fixed monetary amount discounts. This determines how the discount amount is calculated and displayed.
*/
type?: string;
}
```
### SellingPlan
Represents a selling plan (subscription) associated with a line item, containing delivery schedule and plan identification details.
* deliveryInterval
The interval of the selling plan. (DAY, WEEK, MONTH, YEAR).
```ts
string
```
* deliveryIntervalCount
The number of intervals between deliveries.
```ts
number
```
* digest
The fingerprint of the applied selling plan within this cart session. Provided by POS. Not available during refund / exchanges.
```ts
string
```
* id
The unique identifier of the selling plan.
```ts
number
```
* name
The name of the POS device.
```ts
string
```
```ts
export interface SellingPlan {
/**
* The unique identifier of the selling plan.
*/
id: number;
/**
* The name of the POS device.
*/
name: string;
/**
* The fingerprint of the applied selling plan within this cart session. Provided by POS. Not available during refund / exchanges.
*/
digest?: string;
/**
* The interval of the selling plan. (DAY, WEEK, MONTH, YEAR).
*/
deliveryInterval?: string;
/**
* The number of intervals between deliveries.
*/
deliveryIntervalCount?: number;
}
```
Examples
### Examples
* #### Retrieve the line item ID
##### Description
Access the unique identifier of the current cart line item in line item detail contexts. This example shows how to use \`shopify.cartLineItem.id\` to retrieve the line item ID. This can be used for modifying the item, applying discounts, or implementing item-specific functionality.
##### jsx
```jsx
import {render} from 'preact';
export default async () => {
render(, document.body);
};
const Extension = () => {
return (
Cart Line Item ID: {shopify.cartLineItem.uuid}
);
};
```
## Best practices
* **Handle optional properties:** Check for `undefined` in optional properties like `price`, `productId`, `title`, `sku`, and vendor before use.
* **Create contextual experiences:** Use line item data to show different interfaces for gift cards, subscriptions, or vendor-specific information.
* **Implement item-specific validation:** Use properties like `taxable`, `isGiftCard`, and `requiresSellingPlan` for appropriate business logic.
* **Handle selling plans:** When working with subscriptions, check `requiresSellingPlan` and `sellingPlan` to provide appropriate subscription management.
* **Access related data efficiently:** Use `productId` and `variantId` to fetch additional info when needed, but avoid unnecessary API calls.
## Limitations
* Line item data reflects the current state and may not include real-time inventory, pricing, or selling plan updates until the cart is refreshed.
* Selling plan information may be limited during refund or exchange operations where digest values aren't available.