Manage fulfillments with Fulfillment and FulfillmentService resources
This guide explains how to use the Fulfillment and FulfillmentService resources to create and complete fulfillments. You can use these resources either separately or in tandem, depending on your use case.
Fulfillment resources
Before you create fulfillments, it's helpful to understand some of the different fulfillment-related resources:
Order: Contains information about an order, including an array of the line items that were purchased. Line items contain important fulfillment information, such as the associated variant, the quantity purchased, and the fulfillment status.
Location: Represents a geographical location where a line item can be fulfilled. A fulfillment service always has its own location, and variants managed by the fulfillment service should always be fulfilled from that location.
Fulfillment: Represents a shipment of one or more items in an order. It includes the line item that the fulfillment applies to its tracking information, and the location of the fulfillment.
FulfillmentService: Represents a third-party warehousing service that prepares and ships orders on behalf of the store owner. Each fulfillment service is associated with its own location. When you create a fulfillment service, a new location is automatically created and associated with it.
Create a fulfillment
The following steps walk through the process of identifying a line item in an order that needs to be fulfilled and then creating a fulfillment.
Each order includes line items that may be stocked at one or more locations. This means that when you create a fulfillment, you need to specify where you are fulfilling. This helps ShopBase effectively manage inventory for the shop owner.
Step 1 Query the order to see its line items
To get started, retrieve the line items of the order that you want to create fulfillment for.
For more detail, read through the instruction in this link.
Remember to include this code in the test tab for the GET Request:
let response =pm.response.json()if (response.order.line_items[0].length>0){pm.globals.set("variant_id",response.order.line_items[0].variant_id) }
Step 2: Query the variant for its inventory item (optional)
After you've queried the order's line items, you can use variant IDs to find the specific variants that are associated with the inventory item that you want to fulfill.
If an order contains line items without product or variant IDs, then those items can be fulfilled using any of the shop's locations.
In this final step, we already got the fulfillment id (11685344) and the related order. All that is left to be done is sending a POST method to this request URL:
If you are using a ShopBase store without fulfillment services, the fulfillment status will be automatically set to fulfilled. Therefore, the complete fulfillment API only applies to orders created from Fulfillment Services like Printhub or Ali Dropship Connector.