fulfillmentOrder
Returns a Fulfillment order resource by ID.
Anchor to Possible returnsPossible returns
- Anchor to FulfillmentOrderFulfillment•
Order The FulfillmentOrder object represents either an item or a group of items in an Order that are expected to be fulfilled from the same location. There can be more than one fulfillment order for an order at a given location.
Fulfillment orders represent the work which is intended to be done in relation to an order. When fulfillment has started for one or more line items, a Fulfillment is created by a merchant or third party to represent the ongoing or completed work of fulfillment.
See below for more details on creating fulfillments.
NoteShopify creates fulfillment orders automatically when an order is created. It is not possible to manually create fulfillment orders.
See below for more details on the lifecycle of a fulfillment order.
Retrieving fulfillment orders
Fulfillment orders from an order
All fulfillment orders related to a given order can be retrieved with the Order.fulfillmentOrders connection.
API access scopes govern which fulfillments orders are returned to clients. An API client will only receive a subset of the fulfillment orders which belong to an order if they don't have the necessary access scopes to view all of the fulfillment orders.
Fulfillment orders assigned to the app for fulfillment
Fulfillment service apps can retrieve the fulfillment orders which have been assigned to their locations with the assignedFulfillmentOrders connection. Use the
argument to control whether all assigned fulfillment orders should be returned or only those where a merchant has sent a fulfillment request and it has yet to be responded to.
The API client must be granted the
access scope to access the assigned fulfillment orders.
All fulfillment orders
Apps can retrieve all fulfillment orders with the fulfillmentOrders query. This query returns all assigned, merchant-managed, and third-party fulfillment orders on the shop, which are accessible to the app according to the fulfillment order access scopes it was granted with.
The lifecycle of a fulfillment order
Fulfillment Order Creation
After an order is created, a background worker performs the order routing process which determines which locations will be responsible for fulfilling the purchased items. Once the order routing process is complete, one or more fulfillment orders will be created and assigned to these locations. It is not possible to manually create fulfillment orders.
Once a fulfillment order has been created, it will have one of two different lifecycles depending on the type of location which the fulfillment order is assigned to.
The lifecycle of a fulfillment order at a merchant managed location
Fulfillment orders are completed by creating fulfillments. Fulfillments represents the work done.
For digital products a merchant or an order management app would create a fulfilment once the digital asset has been provisioned. For example, in the case of a digital gift card, a merchant would to do this once the gift card has been activated - before the email has been shipped.
On the other hand, for a traditional shipped order, a merchant or an order management app would create a fulfillment after picking and packing the items relating to a fulfillment order, but before the courier has collected the goods.
Learn about managing fulfillment orders as an order management app.
The lifecycle of a fulfillment order at a location which is managed by a fulfillment service
For fulfillment orders which are assigned to a location that is managed by a fulfillment service, a merchant or an Order Management App can send a fulfillment request to the fulfillment service which operates the location to request that they fulfill the associated items. A fulfillment service has the option to accept or reject this fulfillment request.
Once the fulfillment service has accepted the request, the request can no longer be cancelled by the merchant or order management app and instead a cancellation request must be submitted to the fulfillment service.
Once a fulfillment service accepts a fulfillment request, then after they are ready to pack items and send them for delivery, they create fulfillments with the fulfillmentCreate mutation. They can provide tracking information right away or create fulfillments without it and then update the tracking information for fulfillments with the fulfillmentTrackingInfoUpdate mutation.
Learn about managing fulfillment orders as a fulfillment service.
API access scopes
Fulfillment orders are governed by the following API access scopes:
- The
and
access scopes grant access to fulfillment orders assigned to merchant-managed locations.
- The
and
access scopes are intended for fulfillment services. These scopes grant access to fulfillment orders assigned to locations that are being managed by fulfillment services.
- The
and
access scopes grant access to fulfillment orders assigned to locations managed by other fulfillment services.
Fulfillment service app access scopes
Usually, fulfillment services have the
access scope and don't have the
or
access scopes. The app will only have access to the fulfillment orders assigned to their location (or multiple locations if the app registers multiple fulfillment services on the shop). The app will not have access to fulfillment orders assigned to merchant-managed locations or locations owned by other fulfillment service apps.
Order management app access scopes
Order management apps will usually request
and
access scopes. This will allow them to manage all fulfillment orders on behalf of a merchant.
If an app combines the functions of an order management app and a fulfillment service, then the app should request all access scopes to manage all assigned and all unassigned fulfillment orders.
Notifications about fulfillment orders
Fulfillment services are required to register a self-hosted callback URL which has a number of uses. One of these uses is that this callback URL will be notified whenever a merchant submits a fulfillment or cancellation request.
Both merchants and apps can subscribe to the fulfillment order webhooks to be notified whenever fulfillment order related domain events occur.
- The
- Retrieves a list of locations that a fulfillment order can potentially move to.
- Retrieves a specific fulfillment order
- Retrieves fulfillments associated with a fulfillment order
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 query LocationsForMoveList($fulfillmentOrderId: ID!) {6 fulfillmentOrder(id: $fulfillmentOrderId) {7 locationsForMove(first: 10) {8 edges {9 node {10 location {11 id12 name13 }14 message15 movable16 availableLineItemsCount {17 count18 }19 unavailableLineItemsCount {20 count21 }22 }23 }24 }25 }26 }`,27 {28 variables: {29 "fulfillmentOrderId": "gid://shopify/FulfillmentOrder/564786110"30 },31 },32);3334const data = await response.json();35
query LocationsForMoveList($fulfillmentOrderId: ID!) {
fulfillmentOrder(id: $fulfillmentOrderId) {
locationsForMove(first: 10) {
edges {
node {
location {
id
name
}
message
movable
availableLineItemsCount {
count
}
unavailableLineItemsCount {
count
}
}
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query LocationsForMoveList($fulfillmentOrderId: ID!) { fulfillmentOrder(id: $fulfillmentOrderId) { locationsForMove(first: 10) { edges { node { location { id name } message movable availableLineItemsCount { count } unavailableLineItemsCount { count } } } } } }",
"variables": {
"fulfillmentOrderId": "gid://shopify/FulfillmentOrder/564786110"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query LocationsForMoveList($fulfillmentOrderId: ID!) {
fulfillmentOrder(id: $fulfillmentOrderId) {
locationsForMove(first: 10) {
edges {
node {
location {
id
name
}
message
movable
availableLineItemsCount {
count
}
unavailableLineItemsCount {
count
}
}
}
}
}
}`,
{
variables: {
"fulfillmentOrderId": "gid://shopify/FulfillmentOrder/564786110"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query LocationsForMoveList($fulfillmentOrderId: ID!) {
fulfillmentOrder(id: $fulfillmentOrderId) {
locationsForMove(first: 10) {
edges {
node {
location {
id
name
}
message
movable
availableLineItemsCount {
count
}
unavailableLineItemsCount {
count
}
}
}
}
}
}`,
"variables": {
"fulfillmentOrderId": "gid://shopify/FulfillmentOrder/564786110"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query LocationsForMoveList($fulfillmentOrderId: ID!) {
fulfillmentOrder(id: $fulfillmentOrderId) {
locationsForMove(first: 10) {
edges {
node {
location {
id
name
}
message
movable
availableLineItemsCount {
count
}
unavailableLineItemsCount {
count
}
}
}
}
}
}
QUERY
variables = {
"fulfillmentOrderId": "gid://shopify/FulfillmentOrder/564786110"
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "fulfillmentOrderId": "gid://shopify/FulfillmentOrder/564786110"3}
Response
JSON1{2 "fulfillmentOrder": {3 "locationsForMove": {4 "edges": [5 {6 "node": {7 "location": {8 "id": "gid://shopify/Location/346779380",9 "name": "Ottawa Store"10 },11 "message": "No items are stocked at this location.",12 "movable": false,13 "availableLineItemsCount": {14 "count": 015 },16 "unavailableLineItemsCount": {17 "count": 118 }19 }20 },21 {22 "node": {23 "location": {24 "id": "gid://shopify/Location/648019273",25 "name": "Ottawa Store geo located"26 },27 "message": "No items are stocked at this location.",28 "movable": false,29 "availableLineItemsCount": {30 "count": 031 },32 "unavailableLineItemsCount": {33 "count": 134 }35 }36 },37 {38 "node": {39 "location": {40 "id": "gid://shopify/Location/884687543",41 "name": "Ottawa Warehouse"42 },43 "message": "No items are stocked at this location.",44 "movable": false,45 "availableLineItemsCount": {46 "count": 047 },48 "unavailableLineItemsCount": {49 "count": 150 }51 }52 },53 {54 "node": {55 "location": {56 "id": "gid://shopify/Location/124656943",57 "name": "Shipping Origin"58 },59 "message": "Current location.",60 "movable": false,61 "availableLineItemsCount": {62 "count": 063 },64 "unavailableLineItemsCount": {65 "count": 166 }67 }68 },69 {70 "node": {71 "location": {72 "id": "gid://shopify/Location/215093630",73 "name": "Snowdevil Shipwire Warehouse"74 },75 "message": "No items are stocked at this location.",76 "movable": false,77 "availableLineItemsCount": {78 "count": 079 },80 "unavailableLineItemsCount": {81 "count": 182 }83 }84 },85 {86 "node": {87 "location": {88 "id": "gid://shopify/Location/750123840",89 "name": "Toronto Store"90 },91 "message": "No items are stocked at this location.",92 "movable": false,93 "availableLineItemsCount": {94 "count": 095 },96 "unavailableLineItemsCount": {97 "count": 198 }99 }100 },101 {102 "node": {103 "location": {104 "id": "gid://shopify/Location/415211365",105 "name": "US Store"106 },107 "message": "No items are stocked at this location.",108 "movable": false,109 "availableLineItemsCount": {110 "count": 0111 },112 "unavailableLineItemsCount": {113 "count": 1114 }115 }116 }117 ]118 }119 }120}