Mark order fulfilled using GraphQL api

Solved
mtc_dev
Tourist
4 2 0

I am looking to mark order Fulfilled using GraphQL api. 

This is the relevant API documentation I believe: 
https://shopify.dev/api/admin-rest/2021-10/resources/fulfillment#top
But this doesn't explain the theory behind fulfilments.

Can anyone share what steps ar involved in marking an order Fulfilled using GraphQL admin API, please? 

Looking to mark the whole order as fulfilled at first, then on to partial fulfillements. 

Thanks

Accepted Solution (1)

Accepted Solutions
mtc_dev
Tourist
4 2 0

This is an accepted solution.

Answering my own question as usual.

Assuming the order is to be shipped from a single location (which should cover 99% cases), your order will have a single FulfillmentOrder which you need to get the id of

 

{
order(id:"gid://shopify/Order/123456") {
    fulfillmentOrders (first:1) {
      edges {
        node {
          id
        }
      }
    }
  }
}

 

To mark whole order as Fulfilled, use the FulfillmentOrder id to mark the order Fulfilled:

 

sprintf('
            mutation {
                fulfillmentCreateV2(
                    fulfillment: {
                        lineItemsByFulfillmentOrder:{
                            fulfillmentOrderId:"%s"
                        }
                        notifyCustomer:true
                        trackingInfo: {
                            number: "xxx"
                            url: ""
                            company: ""
                        }
                    }
                ) {
                    fulfillment {
                        id
                    }
                }
            }
        ',
            $fulfillment_order_id
        );

To mark individual lines, you'll need to use individual LineItem ids. 

The documentation: 

https://shopify.dev/api/admin-graphql/2021-10/mutations/fulfillmentcreatev2

 

View solution in original post

Reply 1 (1)
mtc_dev
Tourist
4 2 0

This is an accepted solution.

Answering my own question as usual.

Assuming the order is to be shipped from a single location (which should cover 99% cases), your order will have a single FulfillmentOrder which you need to get the id of

 

{
order(id:"gid://shopify/Order/123456") {
    fulfillmentOrders (first:1) {
      edges {
        node {
          id
        }
      }
    }
  }
}

 

To mark whole order as Fulfilled, use the FulfillmentOrder id to mark the order Fulfilled:

 

sprintf('
            mutation {
                fulfillmentCreateV2(
                    fulfillment: {
                        lineItemsByFulfillmentOrder:{
                            fulfillmentOrderId:"%s"
                        }
                        notifyCustomer:true
                        trackingInfo: {
                            number: "xxx"
                            url: ""
                            company: ""
                        }
                    }
                ) {
                    fulfillment {
                        id
                    }
                }
            }
        ',
            $fulfillment_order_id
        );

To mark individual lines, you'll need to use individual LineItem ids. 

The documentation: 

https://shopify.dev/api/admin-graphql/2021-10/mutations/fulfillmentcreatev2

 

View solution in original post