Hi everyone, maybe someone has run into the issue of setting a zero price for an item added through a Cart Transform function’s expand operation.
I’m writing a Cart Transform function. At this stage, the logic is simple: I add a wrapper product to the cart with a JSON attribute that includes both the variant id of product P1 (with a non-zero price) and the variant id of gift product P2 (with a zero price).
I noticed that in this case, add.js returns a 422 error:
{"status":422,"message":"Cart Error","description":"The bundle product 'Wrapper' cannot be added to the cart."}
- but really the wrapper product still gets added to the cart, and the CTA function runs without errors. The output is correct, and the cart shows the right price.
Input:
{
"cart": {
"lines": [
{
"id": "gid://shopify/CartLine/68f8af6e-665b-4522-b25f-e3cd33209f30",
"quantity": 1,
"offer": {
"value": "{\"offer_variant_id\":\"gid://shopify/ProductVariant/42526948458563\",\"offer_name\":\"Test\",\"offer_id\":1,\"items\":[{\"variant_id\":42183658176579,\"price\":90}],\"gifts\":[{\"variant_id\":42183657914435}]}"
},
"merchandise": {
"__typename": "ProductVariant",
"id": "gid://shopify/ProductVariant/42526948458563",
"title": null,
"product": {
"title": "Wrapper",
"handle": "wrapper"
}
}
}
]
}
}
Output:
{
"operations": [
{
"lineExpand": {
"cartLineId": "gid://shopify/CartLine/68f8af6e-665b-4522-b25f-e3cd33209f30",
"expandedCartItems": [
{
"merchandiseId": "gid://shopify/ProductVariant/42183658176579",
"price": {
"adjustment": {
"fixedPricePerUnit": {
"amount": "90"
}
}
},
"quantity": 1
},
{
"merchandiseId": "gid://shopify/ProductVariant/42183657914435",
"price": {
"adjustment": {
"fixedPricePerUnit": {
"amount": "0.0"
}
}
},
"quantity": 1
}
],
"image": null,
"price": null,
"title": "Wrapper"
}
}
]
}
At checkout, I see my wrapper product containing both P1 and P2, but then I encounter an error.
If I set the price > 0 for the gift product, then the add.js request returns 200 and checkout works fine.
What really confuses me is that the Cart Transform function itself doesn’t report any errors. I tested the function, got the correct response, and didn’t expect issues at checkout.
I haven’t found anything in the docs saying that item prices can’t be set to zero.
So I’d like to understand: is this a Shopify bug, or my issue and is there some required workaround for setting a zero price?