0

Get Fulfillment Order

by
Published Nov 8, 2023

Get a fulfillment order by numeric ID or GID: status, assigned location, destination, holds, supported actions, line items and the fulfillments created from it.

Script shopify Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 2 hours ago
1
//native
2

3
/**
4
 * Get Fulfillment Order
5
 * Get a fulfillment order by numeric ID or GID: status, assigned location, destination, holds, supported actions, line items and the fulfillments created from it.
6
 */
7
export async function main(auth: RT.Shopify, fulfillment_order_id: string) {
8
  const response = await fetch(
9
    `https://${auth.store_name}.myshopify.com/admin/api/2026-10/graphql.json`,
10
    {
11
      method: "POST",
12
      headers: {
13
        "X-Shopify-Access-Token": auth.token,
14
        "Content-Type": "application/json",
15
        Accept: "application/json",
16
      },
17
      body: JSON.stringify({
18
        query: `query ($id: ID!) { fulfillmentOrder(id: $id) { id status requestStatus orderId orderName orderProcessedAt createdAt updatedAt fulfillAt fulfillBy assignedLocation { name address1 city countryCode location { id } } destination { firstName lastName company address1 address2 city province zip countryCode email phone } deliveryMethod { methodType } fulfillmentHolds { id reason reasonNotes handle displayReason } supportedActions { action } lineItems(first: 250) { nodes { id sku productTitle variantTitle totalQuantity remainingQuantity requiresShipping lineItem { id } variant { id } } } fulfillments(first: 20) { nodes { id name status createdAt } } } }`,
19
        variables: {
20
          id: fulfillment_order_id.startsWith("gid://")
21
            ? fulfillment_order_id
22
            : `gid://shopify/FulfillmentOrder/${fulfillment_order_id}`,
23
        },
24
      }),
25
    }
26
  )
27

28
  if (!response.ok) {
29
    throw new Error(`${response.status} ${await response.text()}`)
30
  }
31

32
  const { data, errors } = await response.json()
33
  if (errors) {
34
    throw new Error(JSON.stringify(errors))
35
  }
36

37
  if (!data.fulfillmentOrder) {
38
    throw new Error(`Fulfillment order ${fulfillment_order_id} not found`)
39
  }
40

41
  return data.fulfillmentOrder
42
}
43

Other submissions
  • Submitted by hugo697 Typescript (fetch-only)
    Created 528 days ago
    1
    type Shopify = {
    2
      token: string;
    3
      store_name: string;
    4
    };
    5
    /**
    6
     * Retrieves a specific fulfillment order
    7
     * Retrieves a specific fulfillment order.
    8
     */
    9
    export async function main(
    10
      auth: Shopify,
    11
      api_version: string = "2023-10",
    12
      fulfillment_order_id: string
    13
    ) {
    14
      const url = new URL(
    15
        `https://${auth.store_name}.myshopify.com/admin/api/${api_version}/fulfillment_orders/${fulfillment_order_id}.json`
    16
      );
    17
    
    
    18
      const response = await fetch(url, {
    19
        method: "GET",
    20
        headers: {
    21
          "X-Shopify-Access-Token": auth.token,
    22
        },
    23
        body: undefined,
    24
      });
    25
      if (!response.ok) {
    26
        const text = await response.text();
    27
        throw new Error(`${response.status} ${text}`);
    28
      }
    29
      return await response.json();
    30
    }
    31