Skip to main content
Skip to main content

Stock Location Module

The Stock Location Module is the @medusajs/stock-location-next NPM package that provides stock-location-related features in your Medusa and Node.js applications.

It's mainly useful with the Inventory Module.

Note

This module is an updated version of the Stock Location Module part of the multi-warehouse feature. In Medusa V2, the previous version of the module will no longer be in use.

Features

Stock Location Management

Store and manage stock locations. Stock locations can be associated with other models that require a location, such as the Inventory Module's InventoryLevel.

const stockLocation = await stockLocationModuleService.create(
{
name: "Warehouse 1",
}
)

Address Management

A stock location can have detailed address details.

const stockLocation = await stockLocationModuleService.update(
{
id: "sloc_123",
address: {
country_code: "US",
city: "New York City",
address_1: "52 Stone St",
postal_code: "10004",
},
}
)

Configure Stock Location Module

After installing the @medusajs/stock-location package in your Medusa application, add it to the modules object in medusa-config.js:

medusa-config.js
const modules = {
// ...
stockLocationService: {
resolve: "@medusajs/stock-location-next",
},
}

How to Use Stock Location Module's Service

You can use the Stock Location Module's main service by resolving from the dependency container the resource ModuleRegistrationName.STOCK_LOCATION imported from @medusajs/modules-sdk.

For example:

import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStockLocationService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"

export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const stockLocationModuleService: IStockLocationService =
request.scope.resolve(ModuleRegistrationName.STOCK_LOCATION)

res.json({
stock_locations: await stockLocationModuleService.list({}),
})
}
Was this section helpful?