Solved

Unable to update price in CartTransform UpdateOperation

BartekL
Shopify Partner
5 1 1

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.

Accepted Solution (1)

BartekL
Shopify Partner
5 1 1

This is an accepted solution.

Setting 

api_version = "unstable"

in shopify.extension.toml fixed the problem.

View solution in original post

Replies 3 (3)

BartekL
Shopify Partner
5 1 1

This is an accepted solution.

Setting 

api_version = "unstable"

in shopify.extension.toml fixed the problem.

JackLin_PG
Shopify Partner
6 0 1

I also got the error and already set api_version="unstable" but still not work. 

JackLin_PG
Shopify Partner
6 0 1

Oh sorry! It does work thank you