--- title: useApplyCartLinesChange description: Returns a function to mutate the `lines` property of checkout. api_version: 2023-07 api_name: checkout-ui-extensions source_url: html: >- https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/cart/useapplycartlineschange md: >- https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/cart/useapplycartlineschange.md --- # use​Apply​Cart​Lines​Changehook Returns a function to mutate the `lines` property of checkout. ## use​Apply​Cart​Lines​Change() ### Returns * (change: CartLineChange) => Promise\ ### CartLineChange ```ts CartLineAddChange | CartLineRemoveChange | CartLineUpdateChange ``` ### CartLineAddChange * type An identifier for changes that add line items. ```ts "addCartLine" ``` * merchandiseId The merchandise ID being added. ```ts string ``` * quantity The quantity of the merchandise being added. ```ts number ``` * attributes The attributes associated with the line item. ```ts Attribute[] ``` * sellingPlanId The identifier of the selling plan that the merchandise is being purchased with. ```ts string ``` ```ts export interface CartLineAddChange { /** * An identifier for changes that add line items. */ type: 'addCartLine'; /** * The merchandise ID being added. * @example 'gid://shopify/ProductVariant/123' */ merchandiseId: string; /** * The quantity of the merchandise being added. */ quantity: number; /** * The attributes associated with the line item. */ attributes?: Attribute[]; /** * The identifier of the selling plan that the merchandise is being purchased * with. */ sellingPlanId?: SellingPlan['id']; } ``` ### Attribute * key The key for the attribute. ```ts string ``` * value The value for the attribute. ```ts string ``` ```ts export interface Attribute { /** * The key for the attribute. */ key: string; /** * The value for the attribute. */ value: string; } ``` ### CartLineRemoveChange * type An identifier for changes that remove line items. ```ts "removeCartLine" ``` * id Line Item ID. ```ts string ``` * quantity The quantity being removed for this line item. ```ts number ``` ```ts export interface CartLineRemoveChange { /** * An identifier for changes that remove line items. */ type: 'removeCartLine'; /** * Line Item ID. * @example 'gid://shopify/CartLine/123' */ id: string; /** * The quantity being removed for this line item. */ quantity: number; } ``` ### CartLineUpdateChange * type An identifier for changes that update line items. ```ts "updateCartLine" ``` * id Line Item ID. ```ts string ``` * merchandiseId The new merchandise ID for the line item. ```ts string ``` * quantity The new quantity for the line item. ```ts number ``` * attributes The new attributes for the line item. ```ts Attribute[] ``` * sellingPlanId The identifier of the selling plan that the merchandise is being purchased with or \`null\` to remove the the product from the selling plan. ```ts string ``` ```ts export interface CartLineUpdateChange { /** * An identifier for changes that update line items. */ type: 'updateCartLine'; /** * Line Item ID. * @example 'gid://shopify/CartLine/123' */ id: string; /** * The new merchandise ID for the line item. * @example 'gid://shopify/ProductVariant/123' */ merchandiseId?: string; /** * The new quantity for the line item. */ quantity?: number; /** * The new attributes for the line item. */ attributes?: Attribute[]; /** * The identifier of the selling plan that the merchandise is being purchased * with or `null` to remove the the product from the selling plan. */ sellingPlanId?: SellingPlan['id'] | null; } ``` ### CartLineChangeResult ```ts CartLineChangeResultSuccess | CartLineChangeResultError ``` ### CartLineChangeResultSuccess * type Indicates that the line item was changed successfully. ```ts "success" ``` ```ts export interface CartLineChangeResultSuccess { /** * Indicates that the line item was changed successfully. */ type: 'success'; } ``` ### CartLineChangeResultError * type Indicates that the line item was not changed successfully. Refer to the \`message\` property for details about the error. ```ts "error" ``` * message A message that explains the error. This message is useful for debugging. It is \*\*not\*\* localized, and therefore should not be presented directly to the buyer. ```ts string ``` ```ts export interface CartLineChangeResultError { /** * Indicates that the line item was not changed successfully. Refer to the `message` property for details about the error. */ type: 'error'; /** * A message that explains the error. This message is useful for debugging. * It is **not** localized, and therefore should not be presented directly * to the buyer. */ message: string; } ``` ## Related [APIs - StandardApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/standardapi) [APIs - CheckoutApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/checkoutapi) [APIs - OrderStatusApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/orderstatusapi) [APIs - CartLineItemApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/cartlineitemapi) [APIs - PickupPointListApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/pickuppointlistapi) [APIs - PickupLocationListApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/pickuplocationlistapi) [APIs - ShippingOptionItemApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/shippingoptionitemapi) [APIs - ExtensionTargets](https://shopify.dev/docs/api/checkout-ui-extensions/apis/extensiontargets)