docs: edits and fixes to commerce module docs (#7468)

Apply edits and fixes to the commerce modules docs
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-05-29 11:08:06 +00:00
1 parent 130de74d6d
commit 2c5ba408d4
160 files changed
+6400 -3790

No files matched your search

@@ -8,4 +8,10 @@ export const metadata = {
Find in this reference the list of events emitted by the Region Module.
<Note type="soon">
Events are still in development, so this reference will change in the future.
</Note>
<EventsTable />
@@ -263,4 +263,4 @@ In this guide, you’ll find common examples of how you can use the Region Modul
## More Examples
The [Region Module interface reference](/references/region) provides a reference to all the methods available for use with examples for each.
The [Region Module's main service reference](/references/region) provides a reference to all the methods available for use with examples for each.
@@ -8,8 +8,6 @@ export const metadata = {
The Region Module is the `@medusajs/region` NPM package that provides region-related features in your Medusa and Node.js applications.
---
## What is a Region?
A region represents the area you sell products in. Each region can cover multiple countries, but uses a single currency.
@@ -48,7 +46,7 @@ const regions = await regionModuleService.create([
### Different Settings Per Region
Each region has its own settings, such as what countries belong to a region or its tax settings. When using other commerce modules such as the Tax Module or Payment Module, each region has different tax rates, payment providers, and more.
Each region has its own settings, such as what countries belong to a region or its tax settings. Each region has different tax rates, payment providers, and more provided by other commerce modules.
```ts
const regions = await regionModuleService.create([
@@ -62,7 +60,7 @@ const regions = await regionModuleService.create([
name: "United States of America",
currency_code: "usd",
countries: ["us"],
automatic_taxes: false,
payment_providers: ["stripe"]
},
])
```
@@ -71,14 +69,16 @@ const regions = await regionModuleService.create([
## Configure Region Module
After installing the `@medusajs/region` package in your Medusa application, add it to the `modules` object in `medusa-config.js`:
To use the Region Module, enable it in the `modules` object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/modules-sdk")
// ...
const modules = {
// ...
region: {
resolve: "@medusajs/region",
},
[Modules.REGION]: true,
}
```
@@ -137,9 +137,11 @@ For example:
import { IRegionModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
const step1 = createStep("step-1", async (_, context) => {
const step1 = createStep(
"step-1",
async (_, { container }) => {
const regionModuleService: IRegionModuleService =
context.container.resolve(
container.resolve(
ModuleRegistrationName.REGION
)
@@ -4,14 +4,28 @@ 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 Region Module and other Commerce Modules.
This document showcases the link modules defined between the Region Module and other commerce modules.
## Cart Module
Carts are associated with a region. The Medusa application forms a relation between the `Region` and the `Cart` data models.
Carts are associated with a region. Medusa defines a link module that builds a relationship between the `Region` and the `Cart` data models.
![A diagram showcasing an example of how resources from the API Key and Sales Channel modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1711116934/Medusa%20Resources/region-cart_hffaib.jpg)
![A diagram showcasing an example of how resources from the API Key and Sales Channel modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716543714/Medusa%20Resources/customer-region_rtmymb.jpg)
The cart then uses the same currency as the region. During checkout, the cart's taxes, payment, and fulfillment providers are available based on the region's settings.
---
## Order Module
An order is associated with the customer's region. Medusa defines a link module that builds a relationship between the `Order` and `Region` data models.
![A diagram showcasing an example of how data models from the Order and Region modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716555119/Medusa%20Resources/order-region_ihkp2u.jpg)
---
## Payment Module
You can specify for each region which payment providers are available. Medusa defines a link module that builds a relationship between the `PaymentProvider` and the `Region` data models.
![A diagram showcasing an example of how resources from the Payment and Region modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1711569520/Medusa%20Resources/payment-region_jyo2dz.jpg)