I’m facing an issue with the Shopify Cart Transform merge operation where it seems to merge all available quantities of the involved cart lines even when I specify quantity: 1 for each line in the merge payload.
Here’s the situation:
Cart Input
{
"cart": {
"lines": [
{
"id": "gid://shopify/CartLine/LINE_1",
"quantity": 2,
"merchandise": { "id": "gid://shopify/ProductVariant/VARIANT_1" }
},
{
"id": "gid://shopify/CartLine/LINE_2",
"quantity": 2,
"merchandise": { "id": "gid://shopify/ProductVariant/VARIANT_2" }
},
{
"id": "gid://shopify/CartLine/LINE_3",
"quantity": 2,
"merchandise": { "id": "gid://shopify/ProductVariant/VARIANT_3" }
}
]
}
}
Transform Output
{
"operations": [
{
"merge": {
"title": "Bundle Test",
"parentVariantId": "gid://shopify/ProductVariant/BUNDLE_VARIANT",
"cartLines": [
{ "cartLineId": "gid://shopify/CartLine/LINE_1", "quantity": 1 },
{ "cartLineId": "gid://shopify/CartLine/LINE_2", "quantity": 1 },
{ "cartLineId": "gid://shopify/CartLine/LINE_3", "quantity": 1 }
],
"price": { "percentageDecrease": { "value": 50 } }
}
}
]
}
Observed Behavior:
Even though each referenced cart line has 2 units and I specify quantity: 1 in the merge, the result is a single merged bundle with quantity 2 meaning Shopify merged all available units from those lines.
Expected Behavior:
I expected it to merge just 1 unit of each line (to form 1 bundle) and leave the remaining quantity as individual lines.
Question:
-
Is this the intended behavior of the
mergeoperation? -
Does Shopify always merge the entire cart line, regardless of the
quantityvalue? -
If so, is the correct approach to perform a
splitoperation first, and then merge only the new single-quantity lines?
Would appreciate any clarification or confirmation from Shopify or anyone who has implemented similar bundling logic!

