In order to sync the item fulfillment details from NetSuite to Shopify, it is required to get the fulfillment orders object for the order in Shopify. Then, the line items in NetSuite are compared to the fulfillment orders object and update the quantity via mutation.
Query:
query getFulfillmentOrders($afterCursor: String) {
order(id: "gid://shopify/Order/${ORDER_ID}") {
id
fulfillmentOrders(first: 200, after: $afterCursor) {
edges {
node {
id
order {
id
}
status
lineItems(first: 250) {
edges {
node {
id
totalQuantity
remainingQuantity
lineItem {
id
title
}
}
}
}
}
}
}
}
}
This query returns
{
"data": {
"order": {
"id": "gid://shopify/Order/${ORDER_ID}",
"fulfillmentOrders": {
"edges": [
{
"node": {
"id": "gid://shopify/FulfillmentOrder/${FULFILLMENT_ORDER_ID}",
"order": {
"id": "gid://shopify/Order/${ORDER_ID}"
},
"status": "IN_PROGRESS",
"lineItems": {
"edges": [
{
"node": {
"id": "gid://shopify/FulfillmentOrderLineItem/${FULFILLMENT_ORDER_LINE_ITEM_1}",
"totalQuantity": 1,
"remainingQuantity": 0,
"lineItem": {
"id": "gid://shopify/LineItem/${LINE_ITEM_1}",
"title": "Item 1"
}
}
},
{
"node": {
"id": "gid://shopify/FulfillmentOrderLineItem/${FULFILLMENT_ORDER_LINE_ITEM_2}",
"totalQuantity": 1,
"remainingQuantity": 0,
"lineItem": {
"id": "gid://shopify/LineItem/${LINE_ITEM_2}",
"title": "Item 2"
}
}
},
{
"node": {
"id": "gid://shopify/FulfillmentOrderLineItem/${FULFILLMENT_ORDER_LINE_ITEM_3}",
"totalQuantity": 1,
"remainingQuantity": 1,
"lineItem": {
"id": "gid://shopify/LineItem/${LINE_ITEM_3}",
"title": "Item 3"
}
}
}
]
}
}
}
]
}
}
},
"extensions": {
"cost": {
"requestedQueryCost": 263,
"actualQueryCost": 11,
"throttleStatus": {
"maximumAvailable": 2000.0,
"currentlyAvailable": 1989,
"restoreRate": 100.0
}
}
}
}