Files
medusa-store/www/apps/resources/app/commerce-modules/store/page.mdx
Shahed Nasser c1db40b564 docs: added customer storefront guides (#7685)
* added customer guides

* fixes to sidebar

* remove old customer registration guide

* fix build error

* generate files

* run linter
2024-06-13 12:21:54 +03:00

110 lines
2.8 KiB
Plaintext

import { CodeTabs, CodeTab } from "docs-ui"
export const metadata = {
title: `Store Module`,
}
# {metadata.title}
The Store Module is the `@medusajs/store` NPM package that provides store-related features in your Medusa and Node.js applications.
## 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.create({
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.create([
{
name: "USA Store",
supported_currency_codes: ["usd"],
},
{
name: "Europe Store",
supported_currency_codes: ["eur"],
},
])
```
---
## How to Use Store Module's Service
You can use the Store Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.STORE` imported from `@medusajs/modules-sdk`.
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/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const storeModuleService: IStoreModuleService =
request.scope.resolve(ModuleRegistrationName.STORE)
res.json({
stores: await storeModuleService.list(),
})
}
```
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
export default async function subscriberHandler({
container,
}: SubscriberArgs) {
const storeModuleService: IStoreModuleService =
container.resolve(ModuleRegistrationName.STORE)
const stores = await storeModuleService.list()
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
const step1 = createStep(
"step-1",
async (_, { container }) => {
const storeModuleService: IStoreModuleService =
container.resolve(
ModuleRegistrationName.STORE
)
const stores = await storeModuleService.list()
})
```
</CodeTab>
</CodeTabs>