The shipping line can't be updated because it doesn't exist or wasn't added during this edit

Hitting a snag with the orderEditUpdateShippingLine mutation. API version: 2024-10.

The docs seem to be incorrect as to whether the expected input for shippingLineId is a ShippingLine or CalculatedShippingLine.

I’ve actually tried both. When I use the ShippingLine I get “invalid ID” as the error message.

I’m pretty sure it should be CalculatedShippingLine but when I try that I’m getting this error:

The shipping line can’t be updated because it doesn’t exist or wasn’t added during this edit

Even though the shipping line clearly exists in the calculated order:

{
  "id": "gid://shopify/CalculatedOrder/67149234294",
  "shippingLines": [
    {
      "id": "gid://shopify/CalculatedShippingLine/4777590653046",
      "price": {
        "shopMoney": {
          "amount": "500.0"
        }
      }
    }
  ],
  "lineItems": {
    "nodes": [
      {
        "id": "gid://shopify/CalculatedLineItem/14232468324470",
        "sku": "59912709",
        "quantity": 1,
        "originalUnitPriceSet": {
          "shopMoney": {
            "amount": "208.53"
          }
        }
      },
      {
        "id": "gid://shopify/CalculatedLineItem/14232468357238",
        "sku": "59912175",
        "quantity": 1,
        "originalUnitPriceSet": {
          "shopMoney": {
            "amount": "499.5"
          }
        }
      },
      {
        "id": "gid://shopify/CalculatedLineItem/14232468390006",
        "sku": "59011463",
        "quantity": 1,
        "originalUnitPriceSet": {
          "shopMoney": {
            "amount": "799.5"
          }
        }
      }
    ]
  }
}

This is the mutation I’m doing:

mutation orderEditUpdateShippingLine($id: ID!, $shippingLine: OrderEditUpdateShippingLineInput!, $shippingLineId: ID!) {
      orderEditUpdateShippingLine(id: $id, shippingLine: $shippingLine, shippingLineId: $shippingLineId) {
        calculatedOrder {
          id
          shippingLines {
            id
            price {
              shopMoney {
                amount
              }
            }
          }
        }
        userErrors {
          field
          message
        }
      }
    }

With variables:

{
  "id": "gid://shopify/CalculatedOrder/67149234294",
  "shippingLine": {
    "price": {
      "amount": 600,
      "currencyCode": "USD"
    }
  },
  "shippingLineId": "gid://shopify/CalculatedShippingLine/4777590653046"
}

I think I figured it out - you have to do orderEditRemoveShippingLine and then orderEditAddShippingLine instead of orderEditUpdateShippingLine.

Kinda weird. Would be good to get official confirmation.

1 Like

Yeah, the docs need to be a bit more specific. In this changelog, however, they made it clear that orderEditUpdateShippingLine can’t be used to update an existing shipping line:

The mutation orderEditUpdateShippingLine allows you to update the attributes of a newly added shipping line before committing the order edit

Another thing that was confusing to me about this API is how orderEditRemoveShippingLine doesn’t actually remove the shipping lines but just flags them with an isRemoved field, which I only knew about by looking at the payload and couldn’t find anything about it in the documentation (it is, however, also mentioned in the changelog above). And to top it off, the changelog also mentions something very important that explained why my removed shipping lines were still being picked up by a third-party fulfillment app:

The new parameter includeRemovals on the connection order.shippingLines allows you to query removed shipping lines. The default value for this parameter is false, so removed shipping lines will not be returned by default.

For REST API users, removed shipping lines will continue to be returned in the payload of the Order resource. As of API version 2024-04, you can determine whether a shipping line has been removed by checking the value of the new attribute is_removed.

Only this cleared my confusion by suggesting the possibility that the third-party app may still be using the REST API hence why they’re still picking up the removed shipping lines without checking their is_removed value. This is another important information missing from the docs!

1 Like