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 Currency Module.
<Note type="soon">
Events are still in development, so this reference will change in the future.
</Note>
<EventsTable />
@@ -55,7 +55,7 @@ In this guide, you’ll find common examples of how you can use the Currency Mod
---
## Retrieve a Currency by its ID
## Retrieve a Currency by its Code
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
@@ -108,4 +108,4 @@ In this guide, you’ll find common examples of how you can use the Currency Mod
## More Examples
The [Currency Module interface reference](/references/currency) provides a reference to all the methods available for use with examples for each.
The [Currency Module's main service reference](/references/currency) provides a reference to all the methods available for use with examples for each.
@@ -8,23 +8,19 @@ export const metadata = {
The Currency Module is the `@medusajs/currency` NPM package that provides currency-related features in your Medusa and Node.js applications.
---
## Features
### Currency Retrieval
List and retrieve currencies stored in your application.
By default, the module, on application start, adds currencies defined in [this file](https://github.com/medusajs/medusa/blob/develop/packages/utils/src/defaults/currencies.ts) to the database.
```ts
const currency = await currencyModuleService.retrieve("usd")
```
### Support Currencies in Modules
Other commerce modules use currency codes in their models or operations. You can use the Currency Module to retrieve a currency code and its details.
Other commerce modules use currency codes in their data models or operations. You can use the Currency Module to retrieve a currency code and its details.
An example with the Region Module:
@@ -39,14 +35,16 @@ const currency = await currencyModuleService.retrieve(
## Configure Currency Module
After installing the `@medusajs/currency` package in your Medusa application, add it to the `modules` object in `medusa-config.js`:
To use the Currency Module, enable it in the `modules` object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/modules-sdk")
// ...
const modules = {
// ...
currency: {
resolve: "@medusajs/currency",
},
[Modules.CURRENCY]: true,
}
```
@@ -105,9 +103,11 @@ For example:
import { ICurrencyModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
const step1 = createStep("step-1", async (_, context) => {
const step1 = createStep(
"step-1",
async (_, { container }) => {
const currencyModuleService: ICurrencyModuleService =
context.container.resolve(
container.resolve(
ModuleRegistrationName.CURRENCY
)
@@ -0,0 +1,13 @@
export const metadata = {
title: `Relations between Currency Module and Other Modules`,
}
# {metadata.title}
This document showcases the link modules defined between the Currency Module and other commerce modules.
## Store Module
A store has a default currency. Medusa defines a link module that builds a relationship between the `Store` and `Currency` data models.
![A diagram showcasing an example of how resources from the Stock Location and Inventory modules are linked.](https://res.cloudinary.com/dza7lstvk/image/upload/v1716798146/Medusa%20Resources/store-currency_wzftwh.jpg)