docs: edits and fixes to commerce module docs (#7468)
Apply edits and fixes to the commerce modules docs
This commit is contained in:
@@ -8,7 +8,7 @@ In this document, you’ll learn about the main concepts in the Inventory Module
|
||||
|
||||
## InventoryItem
|
||||
|
||||
An inventory item, represented by the `InventoryItem` data model, is a stock-kept item, such as a product, whose inventory can be managed.
|
||||
An inventory item, represented by the [InventoryItem data model](/references/inventory/models/InventoryItem), is a stock-kept item, such as a product, whose inventory can be managed.
|
||||
|
||||
The `InventoryItem` data model mainly holds details related to the underlying stock item, but has relations to other data models that include its inventory details.
|
||||
|
||||
@@ -18,7 +18,7 @@ The `InventoryItem` data model mainly holds details related to the underlying st
|
||||
|
||||
## InventoryLevel
|
||||
|
||||
An inventory level, represented by the `InventoryLevel` data model, holds the inventory and quantity details of an inventory item in a specific location.
|
||||
An inventory level, represented by the [InventoryLevel data model](/references/inventory/models/InventoryLevel), holds the inventory and quantity details of an inventory item in a specific location.
|
||||
|
||||
It has three quantity-related fields:
|
||||
|
||||
@@ -28,9 +28,7 @@ It has three quantity-related fields:
|
||||
|
||||
### Associated Location
|
||||
|
||||
The inventory level's location is determined by the `location_id` field. The Medusa application links the `InventoryLevel` data model with the `StockLocation` data model from the Stock Location Module.
|
||||
|
||||
Learn more about this relation in [this guide](../relations-to-other-modules/page.mdx#stock-location-module)
|
||||
The inventory level's location is determined by the `location_id` field. Medusa links the `InventoryLevel` data model with the `StockLocation` data model from the Stock Location Module.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -8,4 +8,10 @@ export const metadata = {
|
||||
|
||||
Find in this reference the list of events emitted by the Inventory Module.
|
||||
|
||||
<Note type="soon">
|
||||
|
||||
Events are still in development, so this reference will change in the future.
|
||||
|
||||
</Note>
|
||||
|
||||
<EventsTable />
|
||||
@@ -318,7 +318,7 @@ In this document, you’ll find common examples of how you can use the Inventory
|
||||
res.json({
|
||||
is_available: await inventoryModuleService.confirmInventory(
|
||||
request.body.inventory_item_id,
|
||||
request.body.location_id,
|
||||
[request.body.location_id],
|
||||
request.body.required_quantity
|
||||
),
|
||||
})
|
||||
@@ -343,7 +343,7 @@ In this document, you’ll find common examples of how you can use the Inventory
|
||||
return NextResponse.json({
|
||||
is_available: await inventoryModuleService.confirmInventory(
|
||||
body.inventory_item_id,
|
||||
body.location_id,
|
||||
[body.location_id],
|
||||
body.required_quantity
|
||||
),
|
||||
})
|
||||
@@ -569,4 +569,4 @@ In this document, you’ll find common examples of how you can use the Inventory
|
||||
|
||||
## More Examples
|
||||
|
||||
The [module interface reference](/references/inventory-next) provides a reference to all the methods available for use with examples for each.
|
||||
The [Inventory Module's main service reference](/references/inventory-next) provides a reference to all the methods available for use with examples for each.
|
||||
|
||||
@@ -8,7 +8,7 @@ This document explains how the Inventory Module is used within the Medusa applic
|
||||
|
||||
## Product Variant Creation
|
||||
|
||||
When a product variant is created and its `manage_inventory` field's value is `true`, the Medusa application uses the Inventory Module to create an inventory item associated with that product variant.
|
||||
When a product variant is created and its `manage_inventory` field's value is `true`, the Medusa application creates an inventory item associated with that product variant.
|
||||
|
||||

|
||||
|
||||
@@ -16,7 +16,7 @@ When a product variant is created and its `manage_inventory` field's value is `t
|
||||
|
||||
## Add to Cart
|
||||
|
||||
When a product variant with `manage_inventory` set to `true` is added to cart, the Medusa application uses the Inventory Module to check whether there's sufficient stocked quantity. If not, an error is thrown and the product variant won't be added to the cart.
|
||||
When a product variant with `manage_inventory` set to `true` is added to cart, the Medusa application checks whether there's sufficient stocked quantity. If not, an error is thrown and the product variant won't be added to the cart.
|
||||
|
||||

|
||||
|
||||
@@ -24,7 +24,7 @@ When a product variant with `manage_inventory` set to `true` is added to cart, t
|
||||
|
||||
## Order Placed
|
||||
|
||||
When an order is placed, the Medusa application uses the Inventory Module to create a reservation item for each product variant with `manage_inventory` set to `true`. It also sets the `reserved_quantity` of the inventory level associated with the inventory item to the ordered quantity of that item.
|
||||
When an order is placed, the Medusa application creates a reservation item for each product variant with `manage_inventory` set to `true`.
|
||||
|
||||

|
||||
|
||||
@@ -32,11 +32,11 @@ When an order is placed, the Medusa application uses the Inventory Module to cre
|
||||
|
||||
## Order Fulfillment
|
||||
|
||||
When an item in an order is fulfilled and the associated variant has its `manage_inventory` field set to `true`, the Medusa application uses the Inventory Module to:
|
||||
When an item in an order is fulfilled and the associated variant has its `manage_inventory` field set to `true`, the Medusa application:
|
||||
|
||||
- Subtract the `reserved_quantity` from the `stocked_quantity` in the inventory level associated with the variant's inventory item.
|
||||
- Reset the `reserved_quantity` to `0`.
|
||||
- Delete the associated reservation item.
|
||||
- Subtracts the `reserved_quantity` from the `stocked_quantity` in the inventory level associated with the variant's inventory item.
|
||||
- Resets the `reserved_quantity` to `0`.
|
||||
- Deletes the associated reservation item.
|
||||
|
||||

|
||||
|
||||
@@ -44,6 +44,6 @@ When an item in an order is fulfilled and the associated variant has its `manage
|
||||
|
||||
## Order Return
|
||||
|
||||
When an item in an order is returned and the associated variant has its `manage_inventory` field set to `true`, the Medusa application uses the Inventor Module to increment the `stocked_quantity` of the inventory level associated with the inventory item with the returned quantity.
|
||||
When an item in an order is returned and the associated variant has its `manage_inventory` field set to `true`, the Medusa application increments the `stocked_quantity` of the inventory item's level with the returned quantity.
|
||||
|
||||

|
||||
|
||||
@@ -8,12 +8,6 @@ export const metadata = {
|
||||
|
||||
The Inventory Module is the `@medusajs/inventory-next` NPM package that provides inventory-related features in your Medusa and Node.js applications.
|
||||
|
||||
<Note>
|
||||
|
||||
This module is an updated version of the [Inventory Module part of the multi-warehouse feature](../../modules/multiwarehouse/inventory-module.md). In Medusa V2, the previous version of the module will no longer be in use.
|
||||
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
### Inventory Items Management
|
||||
@@ -59,7 +53,7 @@ const reservationItem =
|
||||
|
||||
### Check Inventory Availability
|
||||
|
||||
Check whether an inventory item has the necessary quantity for purchase. Any reserved quantity is considered unavailable, even if the inventory item's quantity hasn't been adjusted yet.
|
||||
Check whether an inventory item has the necessary quantity for purchase. Any reserved quantity is considered unavailable.
|
||||
|
||||
```ts
|
||||
const isAvailable =
|
||||
@@ -74,14 +68,16 @@ const isAvailable =
|
||||
|
||||
## Configure Inventory Module
|
||||
|
||||
After installing the `@medusajs/inventory-next` package in your Medusa application, add it to the `modules` object in `medusa-config.js`:
|
||||
To use the Inventory Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
inventoryService: {
|
||||
resolve: "@medusajs/inventory-next",
|
||||
},
|
||||
[Modules.INVENTORY]: true,
|
||||
}
|
||||
```
|
||||
|
||||
@@ -142,9 +138,11 @@ For example:
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
|
||||
const step1 = createStep("step-1", async (_, context) => {
|
||||
const step1 = createStep(
|
||||
"step-1",
|
||||
async (_, { container }) => {
|
||||
const inventoryModuleService: IInventoryService =
|
||||
context.container.resolve(ModuleRegistrationName.INVENTORY)
|
||||
container.resolve(ModuleRegistrationName.INVENTORY)
|
||||
|
||||
const inventoryItems =
|
||||
await inventoryModuleService.list({})
|
||||
|
||||
+4
-6
@@ -4,15 +4,13 @@ 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 relation between the Inventory Module and other Commerce Modules.
|
||||
This document showcases the link modules defined between the Inventory Module and other commerce modules.
|
||||
|
||||
## Product Module
|
||||
|
||||
Each product variant has different inventory details. The Medusa application forms a relation between the `ProductVariant` and `InventoryItem` data models.
|
||||
Each product variant has different inventory details. Medusa defines a link module that builds a relationship between the `ProductVariant` and `InventoryItem` data models.
|
||||
|
||||

|
||||

|
||||
|
||||
A product variant, whose `manage_inventory` field is enabled, has an associated inventory item. Through that inventory's items relations in the Inventory Module, you can manage and check the variant's inventory quantity.
|
||||
|
||||
@@ -22,6 +20,6 @@ A product variant, whose `manage_inventory` field is enabled, has an associated
|
||||
|
||||
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.
|
||||
|
||||

|
||||

|
||||
|
||||
The stock location provides address details of the location.
|
||||
|
||||
Reference in New Issue
Block a user