Ship from primary
How to fulfill your orders shipping from the primary stock location.

Problem

You have an order containing several SKUs, whose stock is available on different locations and — eventually — belonging to multiple shipping categories. You want to create the shipments just from your primary stock location and perform stock transfers from the secondary locations to the primary one in case the latter cannot fulfill all the order line items.
All the order items are shipped from the primary stock location

Solution

You need to use the ship from primary strategy. To do that, check the related option in the admin UI or send a PATCH request to the inventory_models/:id endpoint, setting the strategy attribute accordingly.

Example

Request
Response
The following request updates the strategy for the inventory model identified by the "BwAezhyOQw" ID:
1
curl -g -X PATCH \
2
'http://yourdomain.commercelayer.io/api/inventory_models/BwAezhyOQw' \
3
-H 'Accept: application/vnd.api+json' \
4
-H 'Authorization: Bearer your-access-token' \
5
-H 'Content-Type: application/vnd.api+json' \
6
-d '{
7
"data": {
8
"type": "inventory_modeld",
9
"id": "BwAezhyOQw",
10
"attributes": {
11
"strategy": "ship_from_primary"
12
}
13
}
14
}'
Copied!
On success, the API responds with a 200 OK status code, returning the updated inventory model object:
1
{
2
"data": {
3
"id": "BwAezhyOQw",
4
"type": "inventory_models",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/inventory_models/BwAezhyOQw"
7
},
8
"attributes": {
9
"name": "EU Inventory Model",
10
"strategy": "ship_from_primary",
11
"stock_locations_cutoff": 3,
12
"created_at": "2018-01-01T12:00:00.000Z",
13
"updated_at": "2018-01-01T12:00:00.000Z",
14
"reference": "ANY-EXTERNAL-REFEFERNCE",
15
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
16
"metadata": {
17
"foo": "bar"
18
}
19
},
20
"relationships": {
21
"inventory_stock_locations": {
22
"links": {
23
"self": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/relationships/inventory_stock_locations",
24
"related": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/inventory_stock_locations"
25
}
26
},
27
"inventory_return_locations": {
28
"links": {
29
"self": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/relationships/inventory_return_locations",
30
"related": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/inventory_return_locations"
31
}
32
},
33
"attachments": {
34
"links": {
35
"self": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/relationships/attachments",
36
"related": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/attachments"
37
}
38
}
39
},
40
"meta": {
41
"mode": "test"
42
}
43
}
44
}
Copied!

How it works

This inventory strategy affects the creation of the resources involved in the process by the following logic.

Shipments

Only the primary stock location is considered for shipment creation.

Stocks transfers

If the primary stock location can fulfill all the SKUs associated with the order, no stock transfers are created. Otherwise, one or more stock transfers are created from the secondary locations to the primary one. Each stock transfer creates a stock line item once completed.

Stock line items

Only the SKUs fulfilled by the primary stock location generate stock line items. Each of the other SKUs generates a stock transfer.

Shipping categories

In case the order contains SKUs belonging to different shipping categories, a shipment is created from the primary stock location for each shipping category. As for the rest, the logic still works as described above.

Additional notes

Do not ship SKU

If an SKU is marked with the do_not_ship flag, no shipment is generated for it.
This option still tracks inventory by creating the necessary stock line items and stock transfers.

Do not track SKU

If an SKU is marked with the do_not_track flag, no stock line item and stock transfer are generated for it.
This option still generates shipments.

More to read

See our documentation if you need more information on how to update an inventory model or if you want more information about SKUs, shipments, stock transfers, and stock line items.