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 Lines API

The API for interacting with the cart lines.

The base API object provided to purchase extension targets.

Anchor to lines
lines
StatefulRemoteSubscribable<[]>
required

A list of lines containing information about the items the customer intends to purchase.

Returns the current line items for the checkout, and automatically re-renders your component if line items are added, removed, or updated.

[]

The API object provided to purchase.checkout extension targets.

Anchor to applyCartLinesChange
applyCartLinesChange
(change: ) => Promise<>
required

Performs an update on the merchandise line items. It resolves when the new line items have been negotiated and results in an update to the value retrieved through the lines property.

Note

This method will return an error if the cart instruction lines.canAddCartLine is false, or the buyer is using an accelerated checkout method, such as Apple Pay, Google Pay, or Meta Pay.

Anchor to useApplyCartLinesChange
useApplyCartLinesChange()

Returns a function to mutate the lines property of checkout.

(change: ) => Promise<>

The API object provided to cart-line-item extension targets.

Anchor to target
target
StatefulRemoteSubscribable<>
required

The cart line the extension is attached to. Until version 2023-04, this property was a StatefulRemoteSubscribable<PresentmentCartLine>.

Returns the cart line the extension is attached to. This hook can only be used by extensions in the purchase.cart-line-item.line-components.render, purchase.checkout.cart-line-item.render-after, and purchase.thank-you.cart-line-item.render-after extension targets. Until version 2023-04, this hook returned a PresentmentCartLine object.

Caution

Deprecated as of version 2023-10, use useCartLineTarget() instead.

Anchor to useCartLineTarget
useCartLineTarget()

Returns the cart line the extension is attached to. This hook can only be used by extensions in the following extension targets:

  • purchase.cart-line-item.line-components.render
  • purchase.checkout.cart-line-item.render-after
  • purchase.thank-you.cart-line-item.render-after



Was this page helpful?