docs: edits and fixes to commerce module docs (#7468)
Apply edits and fixes to the commerce modules docs
This commit is contained in:
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 Tax Module.
|
||||
|
||||
<Note type="soon">
|
||||
|
||||
Events are still in development, so this reference will change in the future.
|
||||
|
||||
</Note>
|
||||
|
||||
<EventsTable />
|
||||
@@ -27,7 +27,7 @@ In this guide, you’ll find common examples of how you can use the Tax Module i
|
||||
)
|
||||
|
||||
const taxRegion = await taxModuleService.createTaxRegions({
|
||||
country_code: "US",
|
||||
country_code: "us",
|
||||
default_tax_rate: {
|
||||
rate: 10,
|
||||
name: "Default rate",
|
||||
@@ -54,7 +54,7 @@ In this guide, you’ll find common examples of how you can use the Tax Module i
|
||||
const taxModuleService = await initializeTaxModule()
|
||||
|
||||
const taxRegion = await taxModuleService.createTaxRegions({
|
||||
country_code: "US",
|
||||
country_code: "us",
|
||||
default_tax_rate: {
|
||||
rate: 10,
|
||||
name: "Default rate",
|
||||
@@ -262,7 +262,7 @@ In this guide, you’ll find common examples of how you can use the Tax Module i
|
||||
import { ITaxModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
|
||||
export async function POST(
|
||||
export async function GET(
|
||||
req: MedusaRequest,
|
||||
res: MedusaResponse
|
||||
): Promise<void> {
|
||||
@@ -312,7 +312,7 @@ In this guide, you’ll find common examples of how you can use the Tax Module i
|
||||
initialize as initializeTaxModule,
|
||||
} from "@medusajs/tax"
|
||||
|
||||
export async function POST(
|
||||
export async function GET(
|
||||
request: Request
|
||||
) {
|
||||
const taxModuleService = await initializeTaxModule()
|
||||
@@ -356,4 +356,4 @@ In this guide, you’ll find common examples of how you can use the Tax Module i
|
||||
|
||||
## More Examples
|
||||
|
||||
The [module interface reference](/references/tax) provides a reference to all the methods available for use with examples for each.
|
||||
The [Tax Module's main service reference](/references/tax) provides a reference to all the methods available for use with examples for each.
|
||||
@@ -8,13 +8,11 @@ export const metadata = {
|
||||
|
||||
The Tax Module is the `@medusajs/tax` NPM package that provides tax-related features in your Medusa and Node.js applications.
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
### Tax Settings Per Region
|
||||
|
||||
Set different tax settings for each region. This is especially useful with the [Region Module](../region/page.mdx).
|
||||
Set different tax settings for each tax region.
|
||||
|
||||
```ts
|
||||
const taxRegion = await taxModuleService.createTaxRegions({
|
||||
@@ -80,14 +78,16 @@ const taxLines = await taxModuleService.getTaxLines(
|
||||
|
||||
## Configure Tax Module
|
||||
|
||||
After installing the `@medusajs/tax` package in your Medusa application, add it to the `modules` object in `medusa-config.js`:
|
||||
To use the Tax Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
tax: {
|
||||
resolve: "@medusajs/tax",
|
||||
},
|
||||
[Modules.TAX]: true,
|
||||
}
|
||||
```
|
||||
|
||||
@@ -151,11 +151,14 @@ For example:
|
||||
import { ITaxModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
|
||||
const step1 = createStep("step-1", async (_, context) => {
|
||||
const step1 = createStep(
|
||||
"step-1",
|
||||
async (_, { container }) => {
|
||||
const taxModuleService: ITaxModuleService =
|
||||
context.container.resolve(
|
||||
container.resolve(
|
||||
ModuleRegistrationName.TAX
|
||||
)
|
||||
|
||||
const taxRegions = await taxModuleService.listTaxRegions()
|
||||
})
|
||||
```
|
||||
|
||||
@@ -8,7 +8,7 @@ In this document, you’ll learn how tax lines are calculated and what a tax pro
|
||||
|
||||
## Tax Lines Calculation
|
||||
|
||||
Tax lines are calculated and retrieved using the `getTaxLines` method of the Tax Module’s main service (`ITaxModuleService`). It accepts an array of line items and shipping methods, and the context of the calculation.
|
||||
Tax lines are calculated and retrieved using the [getTaxLines method of the Tax Module’s main service](/references/tax/getTaxLines). It accepts an array of line items and shipping methods, and the context of the calculation.
|
||||
|
||||
It returns the tax lines that are used to adjust the cart’s tax and grand totals.
|
||||
|
||||
@@ -35,32 +35,24 @@ const taxLines = await taxModuleService.getTaxLines(
|
||||
)
|
||||
```
|
||||
|
||||
The context object is used to determine which tax regions and rates to use in the calculation. The object includes fields related to the address and customer.
|
||||
|
||||
<Note>
|
||||
|
||||
Learn more about the `getTaxLines` method’s parameters and return type in [this reference](/references/tax/getTaxLines).
|
||||
|
||||
</Note>
|
||||
The context object is used to determine which tax regions and rates to use in the calculation. It includes fields related to the address and customer.
|
||||
|
||||
The example above returns the tax lines based on the tax region for the United States.
|
||||
|
||||
---
|
||||
|
||||
## Tax Provider Usage in the Calculation
|
||||
## Using the Tax Provider in the Calculation
|
||||
|
||||
The tax lines retrieved by the `getTaxLines` method are actually retrieved from the tax region’s provider.
|
||||
|
||||
A tax provider is a TypeScript or JavaScript class that implements the logic to shape tax lines. Each tax region has a tax provider.
|
||||
A tax provider module whose main service implements the logic to shape tax lines. Each tax region has a tax provider.
|
||||
|
||||
The Tax Module provides a `system` tax provider that only transforms calculated item and shipping tax rates into the required return type.
|
||||
|
||||
---
|
||||
{/* ---
|
||||
|
||||
TODO add once tax provider guide is updated + add provider modules match other modules.
|
||||
|
||||
## Create Tax Provider
|
||||
|
||||
You can create a tax provider by implementing the `ITaxProvider` imported from `@meduasjs/types`.
|
||||
|
||||
Then, you can add the tax provider to the [providers](../module-options/page.mdx#providers) option and use it to retrieve tax lines.
|
||||
|
||||
Refer to [this reference](/modules/tax/provider) to learn more about creating a tax provider.
|
||||
Refer to [this guide](/modules/tax/provider) to learn more about creating a tax provider. */}
|
||||
@@ -16,15 +16,15 @@ Each tax region has a default tax rate. This tax rate is applied to all taxable
|
||||
|
||||
Tax regions can have parent tax regions. To inherit the tax rates of the parent tax region, set the `is_combinable` of the child’s tax rates to `true`.
|
||||
|
||||
Then, when tax rates are retrieved for a taxable item in the child region, both the child and the parent tax regions’ applicable rates are returned. Otherwise, only the child tax region’s applicable rates are returned.
|
||||
Then, when tax rates are retrieved for a taxable item in the child region, both the child and the parent tax regions’ applicable rates are returned.
|
||||
|
||||
---
|
||||
|
||||
## What are Tax Rules?
|
||||
## Override Tax Rates with Rules
|
||||
|
||||
You can also create tax rates that override the default for specific conditions or rules. For example, the default tax rate is 10%, but for products of type “Shirt” is %15.
|
||||
You can create tax rates that override the default for specific conditions or rules. For example, the default tax rate is 10%, but for products of type “Shirt” is %15.
|
||||
|
||||
A tax region can have multiple tax rates, and each tax rate can have multiple tax rules. The `TaxRateRule` data model represents a tax rate’s rule.
|
||||
A tax region can have multiple tax rates, and each tax rate can have multiple tax rules. The [TaxRateRule data model](/references/tax/models/TaxRateRule) represents a tax rate’s rule.
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -8,18 +8,8 @@ In this document, you’ll learn about tax regions and how to use them with the
|
||||
|
||||
## What is a Tax Region?
|
||||
|
||||
A tax region, represented by the `TaxRegion` data model, stores settings related to a region that your store serves.
|
||||
A tax region, represented by the [TaxRegion data model](/references/tax/models/TaxRegion), stores settings related to a region that your store serves.
|
||||
|
||||
Tax regions can inherit settings and rules from a parent tax region.
|
||||
|
||||
Each tax region has tax rules and a tax provider.
|
||||
|
||||
---
|
||||
|
||||
## Settings Per Region with the Region Module
|
||||
|
||||
By combining the Tax and [Region](../../region/page.mdx) Modules, as done in the Medusa application, each region has its own tax providers and rates.
|
||||
|
||||
This adds more flexibility to your commerce store.
|
||||
|
||||

|
||||
Reference in new issue
Block a user