Introducing our brand new Rules Engine —
Read the docs
LogoLogo
Core APIOther APIsChangelog
How-tos
How-tos
  • Introduction
  • Product discovery
    • Product listing page
    • Product page
  • Placing orders
    • Shopping cart
      • Creating a shopping cart
      • Adding products to cart
      • Updating cart quantities
      • Removing products from cart
      • Displaying the cart summary
    • Checkout
      • Adding the customer
      • Adding a billing address
      • Adding a shipping address
      • Selecting a shipping method
      • Selecting a payment method
      • Adding a payment source
      • Adding a gift card or coupon
      • Placing the order
    • Subscriptions
      • Configuring a subscription model
      • Selecting the source order
      • Generating the subscriptions
      • Updating the subscriptions
    • Payments
      • Adyen
        • Adding the payment source
        • Sending back the payment details
        • Configuring the notification webhooks
        • Reusing the payment source
      • Axerve
        • Adding the payment source
        • Updating the payment intent
      • Braintree
        • Adding the payment source
        • Sending back the payment method nonce
        • Accepting local payments
        • Reusing the payment source
      • Checkout.com
        • Adding the payment source
        • Getting the payment details
        • Refreshing pending transactions
        • Reusing the payment source
      • Klarna
        • Adding the payment source
        • Sending back the authorization token
        • Reusing the payment source
      • PayPal
        • Adding the payment source
        • Preparing the payment for execution
      • Stripe
        • Adding the payment source
        • Refreshing the payment source
        • Reusing the payment source
      • Manual payments
        • Adding a wire transfer payment source
      • External payments
        • Adding the payment source
        • Reusing the payment source
    • Auto-capture
      • Enabling the auto-capture
      • Limiting the auto-capture amount
  • inventory
    • Inventory strategies
      • No split
      • Split shipments
      • Split by line items
      • Ship from first available (or primary)
      • Ship from primary
  • FAQ
    • Environments and initial setup
    • Authentication and access tokens
On this page

Last updated 1 year ago

Problem

You have an order containing several SKUs, whose stock is available in different locations and — possibly — belongs 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's line items.

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

The following request updates the strategy for the inventory model identified by the "BwAezhyOQw" ID:

On success, the API responds with a 200 OK status code, returning the updated inventory model object:

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 transfer is 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. The necessary stock line items and stock transfers are created anyway.

This option still tracks inventory.

Do not track SKU

If an SKU is marked with the do_not_track flag, no stock transfer is generated for it. Stock line items are still created but they aren't associated with any stock item so that the stock isn't decremented/incremented on order placement/cancellation.

This option still generates shipments.

More to read

See our documentation if you need more information on how to or if you want more information about , , , and .

curl -g -X PATCH \
  'http://yourdomain.commercelayer.io/api/inventory_models/BwAezhyOQw' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "inventory_modeld",
    "id": "BwAezhyOQw",
    "attributes": {
      "strategy": "ship_from_primary"
    }
  }
}'
{
  "data": {
    "id": "BwAezhyOQw",
    "type": "inventory_models",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/inventory_models/BwAezhyOQw"
    },
    "attributes": {
      "name": "EU Inventory Model",
      "strategy": "ship_from_primary",
      "stock_locations_cutoff": 3,
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANY-EXTERNAL-REFEFERNCE",
      "reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "inventory_stock_locations": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/relationships/inventory_stock_locations",
          "related": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/inventory_stock_locations"
        }
      },
      "inventory_return_locations": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/relationships/inventory_return_locations",
          "related": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/inventory_return_locations"
        }
      },
      "attachments": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/relationships/attachments",
          "related": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/attachments"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}
  1. inventory
  2. Inventory strategies

Ship from primary

How to fulfill your orders shipping from the primary stock location

PreviousShip from first available (or primary)NextEnvironments and initial setup
  • Problem
  • Solution
  • Example
  • How it works
  • Additional notes
  • More to read
update an inventory model
SKUs
shipments
stock transfers
stock line items
All the order items are shipped from the primary stock location