docs: improved commerce module docs [2/n] (#9501)

Improve + add docs for commerce modules from currency to inventory

[2/n]
This commit is contained in:
Shahed Nasser
2024-10-09 09:53:17 +00:00
committed by GitHub
parent 853187410e
commit 3298cd3fd2
25 changed files with 993 additions and 373 deletions
@@ -10,7 +10,7 @@ In this document, youll learn what a fulfillment module provider is.
A fulfillment module provider handles fulfilling items, typically using a third-party integration.
Fulfillment module providers are stored and represented by the [FulfillmentProvider data model](/references/fulfillment/models/FulfillmentProvider).
Fulfillment module providers registered in the Fulfillment Module's [options](../module-options/page.mdx) are stored and represented by the [FulfillmentProvider data model](/references/fulfillment/models/FulfillmentProvider).
---
@@ -12,7 +12,7 @@ A fulfillment is the shipping and delivery of one or more items to the customer.
---
## Fulfillment Processing
## Fulfillment Processing by a Fulfillment Provider
A fulfillment is associated with a fulfillment provider that handles all its processing, such as creating a shipment for the fulfillments items.
@@ -0,0 +1,43 @@
export const metadata = {
title: `Links between Fulfillment Module and Other Modules`,
}
# {metadata.title}
This document showcases the module links defined between the Fulfillment Module and other commerce modules.
## Order Module
The Order Module provides order-management functionalities.
Medusa defines a link between the `Fulfillment` and `Order` data models. A fulfillment is created for an orders' items.
![A diagram showcasing an example of how data models from the Fulfillment and Order modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716549903/Medusa%20Resources/order-fulfillment_h0vlps.jpg)
A fulfillment is also created for a return's items. So, Medusa defines a link between the `Fulfillment` and `Return` data models.
![A diagram showcasing an example of how data models from the Fulfillment and Order modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1728399052/Medusa%20Resources/Social_Media_Graphics_2024_Order_Return_vetimk.jpg)
---
## Pricing Module
The Pricing Module provides features to store, manage, and retrieve the best prices in a specified context.
Medusa defines a link between the `PriceSet` and `ShippingOption` data models. A shipping option's price is stored as a price set.
![A diagram showcasing an example of how data models from the Pricing and Fulfillment modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716561747/Medusa%20Resources/pricing-fulfillment_spywwa.jpg)
---
## Stock Location Module
The Stock Location Module provides features to manage stock locations in a store.
Medusa defines a link between the `FulfillmentSet` and `StockLocation` data models. A fulfillment set can be conditioned to a specific stock location.
![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)
Medusa also defines a link between the `FulfillmentProvider` and `StockLocation` data models to indicate the providers that can be used in a location.
![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/v1728399492/Medusa%20Resources/fulfillment-provider-stock-location_b0mulo.jpg)
@@ -6,7 +6,7 @@ export const metadata = {
# {metadata.title}
The Fulfillment Module is the `@medusajs/medusa/fulfillment` NPM package that provides fulfillment-related features in your Medusa and Node.js applications.
The Fulfillment Module provides fulfillment-related features in your Medusa and Node.js applications.
## How to Use Fulfillment Module's Service
@@ -15,18 +15,33 @@ You can use the Fulfillment Module's main service by resolving from the Medusa c
For example:
<CodeTabs groupId="resource-type">
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const fulfillmentModuleService = container.resolve(
Modules.FULFILLMENT
)
const fulfillments = await fulfillmentModuleService.listFulfillments()
})
```
</CodeTab>
<CodeTab label="API Route" value="api-route">
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IFulfillmentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const fulfillmentModuleService: IFulfillmentModuleService = req.scope.resolve(
const fulfillmentModuleService = req.scope.resolve(
Modules.FULFILLMENT
)
@@ -39,35 +54,17 @@ export async function GET(
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { IFulfillmentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const fulfillmentModuleService: IFulfillmentModuleService = container.resolve(
const fulfillmentModuleService = container.resolve(
Modules.FULFILLMENT
)
const fulfillments = await fulfillmentModuleService.listFulfillments()
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IFulfillmentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const fulfillmentModuleService: IFulfillmentModuleService = container.resolve(
Modules.FULFILLMENT
)
const fulfillments = await fulfillmentModuleService.listFulfillments()
})
```
</CodeTab>
@@ -1,29 +0,0 @@
export const metadata = {
title: `Relations between Fulfillment Module and Other Modules`,
}
# {metadata.title}
This document showcases the link modules defined between the Fulfillment Module and other commerce modules.
## Order Module
A fulfillment is created for an orders' items. Medusa defines a link module that builds a relationship between the `Fulfillment` and `Order` data models.
![A diagram showcasing an example of how data models from the Fulfillment and Order modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716549903/Medusa%20Resources/order-fulfillment_h0vlps.jpg)
---
## Pricing Module
A shipping option's price is stored as a price set. Medusa defines a link module that builds a relationship between the `PriceSet` and `ShippingOption` data models.
![A diagram showcasing an example of how data models from the Pricing and Fulfillment modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716561747/Medusa%20Resources/pricing-fulfillment_spywwa.jpg)
---
## Stock Location 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)
@@ -45,7 +45,7 @@ These rules are represented by the [ShippingOptionRule data model](/references/f
![A diagram showcasing the relation between shipping option and shipping option rules.](https://res.cloudinary.com/dza7lstvk/image/upload/v1712331340/Medusa%20Resources/shipping-option-rule_oosopf.jpg)
A shipping option can have multiple rules. For example, a shipping option is available if the customer belongs to the VIP group and the total weight is less than 2000g.
A shipping option can have multiple rules. For example, you can add rules to a shipping option so that it's available if the customer belongs to the VIP group and the total weight is less than 2000g.
![A diagram showcasing how a shipping option can have multiple rules.](https://res.cloudinary.com/dza7lstvk/image/upload/v1712331462/Medusa%20Resources/shipping-option-rule-2_ylaqdb.jpg)