Discussing Shopify Functions development, deployment, and usage in Shopify apps.
Hi,
I've got a Shopify Function that uses Cart Transform API. I can update the line item title, but it fails to update the price. I tried the same code as in GitHub sample project ( https://github.com/Shopify/function-examples/blob/cart-transform-dev-preview/sample-apps/update-line... ), but it throws an error.
Function Input:
{ "cart": { "lines": [ { "id": "gid://shopify/CartLine/ddcf3c97-5c1c-4dda-a5c2-d59ef4f55997", "quantity": 1, "cost": { "amountPerQuantity": { "amount": "2.0", "currencyCode": "USD" } }, "merchandise": { "__typename": "ProductVariant", "id": "gid://shopify/ProductVariant/46893488177439", "title": null, "product": { "title": "2000 Calorie Plan" } } } ] } }
Output:
{ "operations": [ { "update": { "cartLineId": "gid://shopify/CartLine/ddcf3c97-5c1c-4dda-a5c2-d59ef4f55997", "title": "2000 Calorie Plan (UPDATED!)", "price": { "adjustment": { "fixedPricePerUnit": { "amount": "123.00" } } } } } ] }
Error Message:
[ { "path": [ "operations", 0, "update", "price" ], "explanation": "Field is not defined on UpdateOperation" } ]
I tried outputting the price as a number and a string, but it didn't make any difference.
Solved! Go to the solution
This is an accepted solution.
Setting
api_version = "unstable"
in shopify.extension.toml fixed the problem.
This is an accepted solution.
Setting
api_version = "unstable"
in shopify.extension.toml fixed the problem.
I also got the error and already set api_version="unstable" but still not work.
Oh sorry! It does work thank you