docs: edits and fixes to commerce module docs (#7468)

Apply edits and fixes to the commerce modules docs
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-05-29 11:08:06 +00:00
1 parent 130de74d6d
commit 2c5ba408d4
160 files changed
+6400 -3790

No files matched your search

@@ -8,4 +8,10 @@ export const metadata = {
Find in this reference the list of events emitted by the Stock Location Module.
<Note type="soon">
Events are still in development, so this reference will change in the future.
</Note>
<EventsTable />
@@ -27,7 +27,7 @@ In this document, you’ll find common examples of how you can use the Stock Loc
const stockLocation = await stockLocationModuleService.create(
{
name: request.body.name,
name: "Warehouse 1",
}
)
@@ -50,11 +50,10 @@ In this document, you’ll find common examples of how you can use the Stock Loc
export async function POST(request: Request) {
const stockLocationModuleService =
await initializeStockLocationModule({})
const body = await request.json()
const stockLocation = await stockLocationModuleService.create(
{
name: body.name,
name: "Warehouse 1",
}
)
@@ -132,17 +131,15 @@ In this document, you’ll find common examples of how you can use the Stock Loc
const stockLocationModuleService: IStockLocationService =
request.scope.resolve(ModuleRegistrationName.STOCK_LOCATION)
const stockLocation = await stockLocationModuleService.update(
{
id: request.params.id,
address: {
country_code: request.body.country_code,
city: request.body.city,
address_1: request.body.address_1,
postal_code: request.body.postal_code,
},
}
)
const stockLocation = await stockLocationModuleService.update({
id: "sloc_123",
address: {
country_code: "US",
city: "New York City",
address_1: "52 Stone St",
postal_code: "10004",
},
})
res.json({
stock_location: stockLocation,
@@ -160,31 +157,21 @@ In this document, you’ll find common examples of how you can use the Stock Loc
initialize as initializeStockLocationModule,
} from "@medusajs/stock-location-next"
type ContextType = {
params: {
id: string
}
}
export async function POST(
request: Request,
{ params }: ContextType
request: Request
) {
const stockLocationModuleService =
await initializeStockLocationModule({})
const body = await request.json()
const stockLocation = await stockLocationModuleService.update(
{
id: params.id,
address: {
country_code: body.country_code,
city: body.city,
address_1: body.address_1,
postal_code: body.postal_code,
},
}
)
const stockLocation = await stockLocationModuleService.update({
id: "sloc_123",
address: {
country_code: "us",
city: "New York City",
address_1: "52 Stone St",
postal_code: "10004",
},
})
return NextResponse.json({
stock_location: stockLocation,
@@ -214,7 +201,7 @@ In this document, you’ll find common examples of how you can use the Stock Loc
const stockLocationModuleService: IStockLocationService =
request.scope.resolve(ModuleRegistrationName.STOCK_LOCATION)
await stockLocationModuleService.delete(request.params.id)
await stockLocationModuleService.delete("sloc_123")
res.status(200)
}
@@ -230,20 +217,13 @@ In this document, you’ll find common examples of how you can use the Stock Loc
initialize as initializeStockLocationModule,
} from "@medusajs/stock-location-next"
type ContextType = {
params: {
id: string
}
}
export async function DELETE(
request: Request,
{ params }: ContextType
request: Request
) {
const stockLocationModuleService =
await initializeStockLocationModule({})
await stockLocationModuleService.delete(params.id)
await stockLocationModuleService.delete("sloc_123")
}
```
@@ -254,4 +234,4 @@ In this document, you’ll find common examples of how you can use the Stock Loc
## More Examples
The [module interface reference](/references/stock-location) provides a reference to all the methods available for use with examples for each.
The [Stock Location Module's main service reference](/references/stock-location) provides a reference to all the methods available for use with examples for each.
@@ -8,19 +8,11 @@ export const metadata = {
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](../inventory/page.mdx).
<Note>
This module is an updated version of the [Stock Location Module part of the multi-warehouse feature](../../modules/multiwarehouse/stock-location-module.md). In Medusa V2, the previous version of the module will no longer be in use.
</Note>
## 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](../inventory/concepts/page.mdx#inventory-level).
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.create(
@@ -32,14 +24,14 @@ const stockLocation = await stockLocationModuleService.create(
### Address Management
A stock location can have detailed address details.
Manage the address of each stock location.
```ts
const stockLocation = await stockLocationModuleService.update(
{
id: "sloc_123",
address: {
country_code: "US",
country_code: "us",
city: "New York City",
address_1: "52 Stone St",
postal_code: "10004",
@@ -52,14 +44,16 @@ const stockLocation = await stockLocationModuleService.update(
## 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`:
To use the Stock Location Module, enable it in the `modules` object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/modules-sdk")
// ...
const modules = {
// ...
stockLocationService: {
resolve: "@medusajs/stock-location-next",
},
[Modules.STOCK_LOCATION]: true,
}
```
@@ -120,9 +114,11 @@ For example:
import { IStockLocationService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
const step1 = createStep("step-1", async (_, context) => {
const step1 = createStep(
"step-1",
async (_, { container }) => {
const stockLocationModuleService: IStockLocationService =
context.container.resolve(
container.resolve(
ModuleRegistrationName.STOCK_LOCATION
)
@@ -4,14 +4,30 @@ export const metadata = {
# {metadata.title}
When Commerce Modules are used together in a Medusa application, the Medusa application handles building the relations between these modules.
This document showcases the link modules defined between the Stock Location Module and other commerce modules.
This document showcases the relation between the Stock Location Module and other Commerce Modules.
## Fulfillment Module
A fulfillment set can be conditioned to a specific stock location. Medusa defines a link module that builds a relationship between the `FulfillmentSet` and `StockLocation` data models.
![A diagram showcasing an example of how data models from the Fulfillment and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1712567101/Medusa%20Resources/fulfillment-stock-location_nlkf7e.jpg)
---
## Inventory Module
Reservation items and inventory items are associated with a location. The Medusa application forms a relation between the `ReservationItem` and `StockLocation` data models, and the `InventoryLevel` and `StockLocation` data models.
Reservation items and inventory items are associated with a location. Medusa defines a link module that builds a relationship between the `ReservationItem` and `StockLocation` data models, and the `InventoryLevel` and `StockLocation` data models.
![A diagram showcasing an example of how resources from the Stock Location and Inventory modules are linked.](https://res.cloudinary.com/dza7lstvk/image/upload/v1709716521/Medusa%20Resources/stock-location-inventory_logsrt.jpg)
![A diagram showcasing an example of how resources from the Stock Location and Inventory modules are linked.](https://res.cloudinary.com/dza7lstvk/image/upload/v1709660383/Medusa%20Resources/inventory-stock-location_yp26k3.jpg)
With this relation, stock and reserved quantity is specific to a location, providing you with more flexibility. The location can be as simple as having only a name, and more flexible by adding more address details to it.
---
## Sales Channel Module
A stock location is associated with a sales channel. This scopes inventory quantities associated with that stock location by the associated sales channel.
Medusa defines a link module that builds a relationship between the `SalesChannel` and `StockLocation` data models.
![A diagram showcasing an example of how resources from the Sales Channel and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716796872/Medusa%20Resources/sales-channel-location_cqrih1.jpg)