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
@@ -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>