orderEditAddVariant not returning added item in the calculatedOrder

Solved
longinoa
Excursionist
15 1 0

Based on the documentation of https://shopify.dev/docs/admin-api/graphql/reference/orders/ordereditaddvariant the calculatedOrder should contain all edits - however I am not seeing this in orderEditAddVariant.

I see the other edit I have made (deleting the first item) however the newly added one is not present. I am assuming I can get it from calculatedLineItem but I wanted to keep parsing of my calculatedOrder in one place.

graphql:

mutation addVariantToOrder($id: ID!, $variantId: ID!, $quantity: Int!) {
  orderEditAddVariant(id: $id, variantId: $variantId, quantity: $quantity) {
    calculatedOrder{
      id,
      lineItems(first:30) {
        edges{
          node{
            id,
            quantity,
            variant{
              id
            },
          }
        }
        pageInfo{
          hasNextPage,
          hasPreviousPage
        }
      },
      
    }
    userErrors{
      field,
      message
    }
  }
}

 

Variables:

{
  "id":"gid://shopify/CalculatedOrder/12189204655",
"variantId": "gid://shopify/ProductVariant/38279263551663",
"quantity": 1
}

 

result:

{
  "data": {
    "orderEditAddVariant": {
      "calculatedOrder": {
        "id": "gid://shopify/CalculatedOrder/12189204655",
        "lineItems": {
          "edges": [
            {
              "node": {
                "id": "gid://shopify/CalculatedLineItem/9628516024495",
                "quantity": 0,
                "variant": {
                  "id": "gid://shopify/ProductVariant/38154888315055"
                }
              }
            }
          ],
          "pageInfo": {
            "hasNextPage": false,
            "hasPreviousPage": false
          }
        }
      },
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 72,
      "actualQueryCost": 14,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 986,
        "restoreRate": 50
      }
    }
  }
}

 

0 Likes
longinoa
Excursionist
15 1 0

This is an accepted solution.

Ahhh nevermind - these are in the `addedItems`

add this to your query to get them

addedLineItems(first:5) {
        edges{
          node{
            id
            quantity
            variant{id}
          }
        }
        pageInfo{
          hasNextPage,
          hasPreviousPage
        }
      }

 

0 Likes