Files
medusa-store/www/apps/resources/app/commerce-modules/store/page.mdx

107 lines
2.7 KiB
Plaintext

import { CodeTabs, CodeTab } from "docs-ui"
export const metadata = {
title: `Store Module`,
}
# {metadata.title}
The Store Module is the `@medusajs/medusa/store` NPM package that provides store-related features in your Medusa and Node.js applications.
## How to Use Store Module's Service
You can use the Store Module's main service by resolving from the Medusa container the resource `Modules.STORE` imported from `@medusajs/framework/utils`.
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/framework/http"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const storeModuleService: IStoreModuleService = request.scope.resolve(
Modules.STORE
)
res.json({
stores: await storeModuleService.listStores(),
})
}
```
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const storeModuleService: IStoreModuleService = container.resolve(
Modules.STORE
)
const stores = await storeModuleService.listStores()
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const storeModuleService: IStoreModuleService = container.resolve(
Modules.STORE
)
const stores = await storeModuleService.listStores()
})
```
</CodeTab>
</CodeTabs>
---
## Features
### Store Management
A store holds the main configurations of your commerce store, such as supported currencies, default region and sales channel, and more.
```ts
const store = await storeModuleService.createStores({
name: "My Store",
supported_currency_codes: ["usd"],
})
```
### Multi-Tenancy Support
You can create multiple stores, each having its own configurations.
```ts
const stores = await storeModuleService.createStores([
{
name: "USA Store",
supported_currency_codes: ["usd"],
},
{
name: "Europe Store",
supported_currency_codes: ["eur"],
},
])
```