Cart Transform API reference
The Cart Transform API enables you to expand cart line items and update the presentation of cart line items.
Extension targets
Anchor link to section titled "Extension targets"The Cart Transform API exposes the following targets:
Target | Output type | Description |
---|---|---|
purchase.cart-transform.run |
FunctionRunResult | Outputs the cart transform operations |
The RunInput
object is the complete schema that your function can receive as input.
For a list of fields that the Cart Transform API's Input
object accepts, refer to Input.
The following example shows an input query:
The following example shows the resulting input to the query:
FunctionRunResult
Anchor link to section titled "FunctionRunResult"The FunctionRunResult
object is the expected output for the purchase.cart-transform.run
target.
The output returns a list of cart operations, 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 into2x Face mask
and1 cream
.MergeOperation
: Enable merging items together into a bundle by specifying the bundle's product parent. For example, the items1x Burger
,1x Coke
, and2x Fries
can be combined into theMeal 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.
The following example shows an input query:
The following function result uses all operations on the single Transform Cart API:
Invalid operations
Anchor link to section titled "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
andPriceAdjustment
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.
For more information and examples, refer to the Cart Transform API.