Files
medusa-store/www/apps/resources/app/commerce-modules/stock-location/page.mdx
Shahed Nasser 964927b597 docs: general fixes and improvements (#7918)
* docs improvements and changes

* updated module definition

* modules + dml changes

* fix build

* fix vale error

* fix lint errors

* fixes to stripe docs

* fix condition

* fix condition

* fix module defintion

* fix checkout

* disable UI action

* change oas preview action

* flatten provider module options

* fix lint errors

* add module link docs

* pr comments fixes

* fix vale error

* change node engine version

* links -> linkable

* add note about database name

* small fixes

* link fixes

* fix response code in api reference

* added migrations step
2024-07-04 17:26:03 +03:00

104 lines
3.0 KiB
Plaintext

import { CodeTabs, CodeTab } from "docs-ui"
export const metadata = {
title: `Stock Location Module`,
}
# {metadata.title}
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.
## Features
### Stock Location Management
Store and manage stock locations. Stock locations are associated with data models of other modules that require a location, such as the [Inventory Module's InventoryLevel](../inventory/concepts/page.mdx#inventory-level).
```ts
const stockLocation = await stockLocationModuleService.createStockLocations({
name: "Warehouse 1",
})
```
### Address Management
Manage the address of each stock location.
```ts
const stockLocation = await stockLocationModuleService.updateStockLocations({
id: "sloc_123",
address: {
country_code: "us",
city: "New York City",
address_1: "52 Stone St",
postal_code: "10004",
},
})
```
---
## How to Use Stock Location Module's Service
You can use the Stock Location Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.STOCK_LOCATION` imported from `@medusajs/modules-sdk`.
For example:
<CodeTabs groupId="resource-type">
<CodeTab label="API Route" value="api-route">
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStockLocationService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
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.listStockLocations({}),
})
}
```
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IStockLocationService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const stockLocationModuleService: IStockLocationService = container.resolve(
ModuleRegistrationName.STOCK_LOCATION
)
const stockLocations = await stockLocationModuleService.listStockLocations({})
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IStockLocationService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const stockLocationModuleService: IStockLocationService = container.resolve(
ModuleRegistrationName.STOCK_LOCATION
)
const stockLocations = await stockLocationModuleService.listStockLocations({})
})
```
</CodeTab>
</CodeTabs>