Skip to main content
Migrate to Polaris

Version 2025-07 is the last API version to support React-based UI components. Later versions use web components, native UI elements with built-in accessibility, better performance, and consistent styling with Shopify's design system. Check out the migration guide to upgrade your extension.

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.

  • Line item details: Display detailed information about the current line item including product details and pricing.
  • Item-specific actions: Implement actions and workflows based on product type or custom properties.
  • Contextual UI: Create interfaces that adapt based on line item characteristics.
  • Discount management: Access line item discounts to create specialized discount display interfaces.

The Cart Line Item API object provides read-only access to a specific line item in the cart. Access the following properties on the API object to get line item details like product information, pricing, discounts, and custom properties.

Anchor to cartLineItem
cartLineItem
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.


  • Use line item context effectively: Use the line item data to create contextual experiences—for example, showing different interfaces for gift cards versus regular products, or displaying vendor-specific information.
  • Implement item-specific validation: Use line item properties like taxable and isGiftCard to implement appropriate validation and business logic for different item types.
  • Access related data efficiently: Use productId and variantId to fetch additional product information when needed, but avoid unnecessary API calls by using the data already available in the line item.

  • The API provides read-only access to line item data—use the Cart API for modifying line item properties, discounts, or other attributes.
  • Line item data reflects the current state and may not include real-time inventory or pricing updates until the cart is refreshed.

Was this page helpful?