The Cart Transform API enables you to expand cart line items and update the presentation of cart line items. ## Extension targets The Cart Transform API exposes the following [targets](/docs/apps/build/app-extensions/configure-app-extensions#targets): | Target | Output type | Description | | ------ | ----------- | ----------- | | `purchase.cart-transform.run` | [FunctionRunResult](#functionrunresult) | Outputs the cart transform operations | ## Input The `RunInput` object is the complete schema that your function can receive as [input](/docs/apps/build/functions/input-output#input). For a list of fields that the Cart Transform API's `Input` object accepts, refer to [Input](/docs/api/functions/reference/cart-transform/graphql/input). ### Example The following example shows an input query:

The following example shows the resulting input to the query:

## FunctionRunResult The [`FunctionRunResult`](/docs/api/functions/reference/cart-transform/graphql/functionrunresult) object is the expected [output](/docs/apps/build/functions/input-output#output) for the `purchase.cart-transform.run` target. The output returns a list of [cart operations](/docs/api/functions/reference/cart-transform/graphql/common-objects/cartoperation), where each element can have one of the following values: - **`ExpandOperation`:** Specify the components of an item and apply a price adjustment. For example, `Skin care kit` is expanded into `2x Face mask` and `1 cream`. - **`MergeOperation`**: Enable merging items together into a bundle by specifying the bundle's product parent. For example, the items `1x Burger`, `1x Coke`, and `2x Fries` can be combined into the `Meal Kit` product, resulting in one item (`Meal Kit`) with three components. In the case where the function returns multiple operations and there's a collision, Shopify executes a subset of the operations using the following criteria: - **Multiple expand operations targeting the same cart line:** The first expand operation in the list is executed, and all other expand operations for the same cart line are discarded. - **Multiple merge operations targeting the same cart line:** The first merge operation in the list is executed, and all other merge operations for the same cart line are discarded. - **Expand and merge operations targeting the same cart line:** The expand operation is executed, and the merge operation is discarded. ### Example The following example shows an input query:

The following function result uses all operations on the single Transform Cart API:

## Invalid operations The following scenarios are considered as invalid: `expand` operations: - One of the component quantities is less than 0. - The line to be expanded doesn't exist. - One of the component variant IDs doesn't exist. - Both `ExpandedItem.Price` and `PriceAdjustment` are returned in the operation. - One of the components is given a price less than 0. - Some of the components have a customized price and others don't. `merge` operations: - The merge operation contains an invalid quantity for the children (less than 0 or the quantity to merge is bigger than the line's quantity). - The parent variant ID doesn't exist. - One of the lines to be merged doesn't exist. `update` operations: - The operation includes a price < 0. - The line to be updated doesn't exist. - The operation targets a line that is going to be expanded or merged. - The shop is not on a Plus plan or a Development store plan. > Note: > The `expand`, `merge`, and `update` operations will be dropped in the event that a selling plan is present. --- For more information and examples, refer to the [Cart Transform API](docs/api/functions/reference/cart-transform).