Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

fulfillmentOrderLineItems in fulfillmentCreateV2

fulfillmentOrderLineItems in fulfillmentCreateV2

CedrusBlackieer
Shopify Partner
1 0 0

As documentation, fulfillmentCreateV2 needs to declare fulfillmentOrderLineItems to know which LineItem fulfilled.

But FulfillmentOrderLineItem.lineItem will be deprecated (https://shopify.dev/api/admin-graphql/2022-04/objects/FulfillmentOrderLineItem)

 

So, how can I get exactly fulfillmentOrderLineItems of the LineItem to use?

Thank you.

Cedrus
Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 239 534

Hi @CedrusBlackieer 👋

 

The `FulfillmentOrderLineItemsInput.fulfillmentOrderLineItems` field of the `fulfillmentCreateV2` consists of `FulfillmentOrderLineItemInput.id` and `FulfillmentOrderLineItemInput.quantity`. Once fulfillment has been assigned and your app has accepted  the fulfillment request, the resulting payloads will contain the `id` and `quantity` required as part of `FulfillmentOrderLineItemInput`.

 

Below is an example assignment query and response:

 

{
    shop {
        assignedFulfillmentOrders(first: 10) {
            nodes {
                id
                lineItems(first: 10) {
                    nodes {
                        id
                        remainingQuantity
                    }
                }
            }
        }
    }
}

 

Response:

 

{
    "data": {
        "shop": {
            "assignedFulfillmentOrders": {
                "nodes": [{
                    "id": "gid://shopify/FulfillmentOrder/123",
                    "lineItems": {
                        "nodes": [{
                            "id": "gid://shopify/FulfillmentOrderLineItem/456",
                            "remainingQuantity": 10
                        }]
                    }
                }]
            } ...

 

 

Then the fulfillment can be created using `fulfillmentCreateV2` mutation as follows:

 

mutation ($input: FulfillmentV2Input!) {
    fulfillmentCreateV2(fulfillment: $input) {
        fulfillment {
            id
            status
        }
    }
}

 

With variable inputs:

 

{
    "input": {
        "lineItemsByFulfillmentOrder": [{
            "fulfillmentOrderId": "gid://shopify/FulfillmentOrder/123",
            "fulfillmentOrderLineItems": {
            "id": "gid://shopify/FulfillmentOrderLineItem/456",
            "quantity": 2
            }
        }]
    }
}

 

 

Hope that helps!

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog