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
2024-05-29 11:08:06 +00:00
committed by GitHub
parent 130de74d6d
commit 2c5ba408d4
160 changed files with 6400 additions and 3790 deletions
@@ -10,7 +10,7 @@ In this document, youll learn about some basic fulfillment concepts.
A fulfillment set is a general form or way of fulfillment. For example, shipping is a form of fulfillment, and pick-up is another form of fulfillment. Each of these can be created as fulfillment sets.
A fulfillment set is represented by the `FulfillmentSet` data model. All other configurations, options, and management features are related to a fulfillment set, in one way or another. So, the first step when using the Fulfillment Module is to create a fulfillment set.
A fulfillment set is represented by the [FulfillmentSet data model](/references/fulfillment/models/FulfillmentSet). All other configurations, options, and management features are related to a fulfillment set, in one way or another.
```ts
const fulfillmentSets = await fulfillmentModuleService.create(
@@ -33,13 +33,11 @@ const fulfillmentSets = await fulfillmentModuleService.create(
A service zone is a collection of geographical zones or areas. Its used to restrict available shipping options to a defined set of locations.
A service zone is represented by the `ServiceZone` data model. Its associated with a fulfillment set, as each service zone is specific to a form of fulfillment. For example, if a customer chooses to pick up items, you can restrict the available shipping options based on their location.
A service zone is represented by the [ServiceZone data model](/references/fulfillment/models/ServiceZone). Its associated with a fulfillment set, as each service zone is specific to a form of fulfillment. For example, if a customer chooses to pick up items, you can restrict the available shipping options based on their location.
A fulfillment set can have multiple service zones, each restricting different locations.
![A diagram showcasing the relation between fulfillment sets, service zones, and geo zones](https://res.cloudinary.com/dza7lstvk/image/upload/v1712329770/Medusa%20Resources/service-zone_awmvfs.jpg)
![https://res.cloudinary.com/dza7lstvk/image/upload/v1712329770/Medusa%20Resources/service-zone_awmvfs.jpg](https://res.cloudinary.com/dza7lstvk/image/upload/v1712329770/Medusa%20Resources/service-zone_awmvfs.jpg)
A service zone can have multiple geographical zones, each represented by the `GeoZone` data model. It holds location-related details to narrow down supported areas, such as country, city, or province code.
A service zone can have multiple geographical zones, each represented by the [GeoZone data model](/references/fulfillment/models/GeoZone). It holds location-related details to narrow down supported areas, such as country, city, or province code.
---
@@ -47,4 +45,4 @@ A service zone can have multiple geographical zones, each represented by the `Ge
A shipping profile defines a type of items that are shipped in a similar manner. For example, a `default` shipping profile is used for all item types, but the `digital` shipping profile is used for digital items that arent shipped and delivered conventionally.
A shipping profile is represented by the `ShippingProfile` data model. It only defines the profiles details, but its associated with the shipping options available for the item type.
A shipping profile is represented by the [ShippingProfile data model](/references/fulfillment/models/ShippingProfile). It only defines the profiles details, but its associated with the shipping options available for the item type.
@@ -8,4 +8,10 @@ export const metadata = {
Find in this reference the list of events emitted by the Fulfillment Module.
<Note type="soon">
Events are still in development, so this reference will change in the future.
</Note>
<EventsTable />
@@ -1,25 +1,27 @@
export const metadata = {
title: `Fulfillment Provider`,
title: `Fulfillment Provider Module`,
}
# {metadata.title}
In this document, youll learn what a fulfillment provider is.
In this document, youll learn what a fulfillment provider module is.
## Whats a Fulfillment Provider?
## Whats a Fulfillment Provider Module?
A fulfillment provider implements the functionality of fulfilling items, typically using a third-party integration. Its represented by the `FulfillmentProvider` data model.
A fulfillment provider module handles fulfilling items, typically using a third-party integration.
---
## How to Create a Fulfillment Provider?
A fulfillment provider is a TypeScript or JavaScript class that extends the `AbstractFulfillmentProviderService` class imported from `@medusajs/utils`. You can create it part of your Medusa application codebase, in a plugin, or in a provider module.
Fulfillment provider modules are stored and represented by the [FulfillmentProvider data model](/references/fulfillment/models/FulfillmentProvider).
---
## Configure Fulfillment Providers
The Fulfillment Module accepts a `providers` option that allows you to register providers in your application. When the Medusa application starts, it registers these modules and adds records of the `FulfillmentProvider` for them.
The Fulfillment Module accepts a `providers` option that allows you to register providers in your application.
Learn more about the `providers` option in [this documentation](../module-options/page.mdx).
---
## How to Create a Fulfillment Provider?
Refer to [this guide](/references/fulfillment/provider) to learn how to create a fulfillment provider module.
@@ -8,7 +8,7 @@ In this document, youll learn about the concepts of item fulfillment.
## Fulfillment Data Model
A fulfillment is the shipping and delivery of one or more items to the customer. Its represented by the `Fulfillment` data model.
A fulfillment is the shipping and delivery of one or more items to the customer. Its represented by the [Fulfillment data model](/references/fulfillment/models/Fulfillment).
---
@@ -18,7 +18,7 @@ A fulfillment is associated with a fulfillment provider that handles all its pro
The fulfillment is also associated with a shipping option of that provider, which determines how the item is shipped.
![https://res.cloudinary.com/dza7lstvk/image/upload/v1712331947/Medusa%20Resources/fulfillment-shipping-option_jk9ndp.jpg](https://res.cloudinary.com/dza7lstvk/image/upload/v1712331947/Medusa%20Resources/fulfillment-shipping-option_jk9ndp.jpg)
![A diagram showcasing the relation between a fulfillment, fulfillment provider, and shipping option](https://res.cloudinary.com/dza7lstvk/image/upload/v1712331947/Medusa%20Resources/fulfillment-shipping-option_jk9ndp.jpg)
---
@@ -36,7 +36,7 @@ A fulfillment is used to fulfill one or more items. Each item is represented by
The fulfillment item holds details relevant to fulfilling the item, such as barcode, SKU, and quantity to fulfill.
![https://res.cloudinary.com/dza7lstvk/image/upload/v1712332114/Medusa%20Resources/fulfillment-item_etzxb0.jpg](https://res.cloudinary.com/dza7lstvk/image/upload/v1712332114/Medusa%20Resources/fulfillment-item_etzxb0.jpg)
![A diagram showcasing the relation between fulfillment and fulfillment items.](https://res.cloudinary.com/dza7lstvk/image/upload/v1712332114/Medusa%20Resources/fulfillment-item_etzxb0.jpg)
---
@@ -14,7 +14,7 @@ In this document, you'll learn about the options of the Fulfillment Module.
## providers
The `providers` option is an array of either fulfillment provider modules, fulfillment plugins, or path to a file that holds a fulfillment provider.
The `providers` option is an array of fulfillment provider modules.
When the Medusa application starts, these providers are registered and can be used to process fulfillments.
@@ -29,6 +29,13 @@ const modules = {
providers: [
{
resolve: `@medusajs/fulfillment-manual`,
options: {
config: {
manual: {
// provider options...
}
}
}
},
],
},
@@ -38,5 +45,6 @@ const modules = {
The `providers` option is an array of objects that accept the following properties:
- `resolve`: A string indicating the package name of the fulfillment provider module or the fulfillment plugin, or the path to the file defining the fulfillment provider.
- `options`: An optional object of options to pass to the fulfillment provider.
- `resolve`: A string indicating either the package name of the fulfillment provider module or the path to it.
- `options`: An optional object of the fulfillment provider module's options. The object must have the following property:
- `config`: An object whose key is the ID of the fulfillment provider, and its value is an object of options to pass to the provider module.
@@ -8,13 +8,11 @@ export const metadata = {
The Fulfillment Module is the `@medusajs/fulfillment` NPM package that provides fulfillment-related features in your Medusa and Node.js applications.
---
## Features
### Fulfillment Management
Create fulfillments and keep track of their statuses, items, and more.
Create fulfillments and keep track of their status, items, and more.
```ts
const fulfillment =
@@ -46,7 +44,6 @@ Use third-party fulfillment providers to provide customers with shipping options
```ts
const shippingOption =
await fulfillmentModuleService.createShippingOptions({
name: "Express shipping",
// ...
provider_id: "webshipper",
})
@@ -109,12 +106,14 @@ const fulfillmentSets = await fulfillmentModuleService.create(
## Configure Fulfillment Module
After installing the `@medusajs/fulfillment` package in your Medusa application, add it to the `modules` object in `medusa-config.js`:
To use the Fulfillment Module, enable it in the `modules` object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/modules-sdk")
const modules = {
// ...
fulfillment: {
[Modules.FULFILLMENT]: {
resolve: "@medusajs/fulfillment",
providers: [
// ...
@@ -184,11 +183,14 @@ For example:
import { IFulfillmentModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
const step1 = createStep("step-1", async (_, context) => {
const step1 = createStep(
"step-1",
async (_, { container }) => {
const fulfillmentModuleService: IFulfillmentModuleService =
context.container.resolve(
container.resolve(
ModuleRegistrationName.FULFILLMENT
)
const fulfillments =
await fulfillmentModuleService.listFulfillments()
})
@@ -4,14 +4,26 @@ 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 link modules defined between the Fulfillment Module and other commerce modules.
This document showcases the relation between the Fulfillment Module and other Commerce Modules.
## Order Module
A fulfillment is created for an orders' items. Medusa defines a link module that builds a relationship between the `Fulfillment` and `Order` data models.
![A diagram showcasing an example of how data models from the Fulfillment and Order modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716549903/Medusa%20Resources/order-fulfillment_h0vlps.jpg)
---
## Pricing Module
A shipping option's price is stored as a price set. Medusa defines a link module that builds a relationship between the `PriceSet` and `ShippingOption` data models.
![A diagram showcasing an example of how data models from the Pricing and Fulfillment modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716561747/Medusa%20Resources/pricing-fulfillment_spywwa.jpg)
---
## Stock Location Module
When the Fulfillment and Stock Location modules are used together, a fulfillment set can be conditioned to a specific stock location.
A fulfillment set can be conditioned to a specific stock location. Medusa defines a link module that builds a relationship between the `FulfillmentSet` and `StockLocation` data models.
The Medusa application forms a relation between the `FulfillmentSet` and `StockLocation` data models.
![A diagram showcasing an example of how resources from the Fulfillment and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1712567101/Medusa%20Resources/fulfillment-stock-location_nlkf7e.jpg)
![A diagram showcasing an example of how data models from the Fulfillment and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1712567101/Medusa%20Resources/fulfillment-stock-location_nlkf7e.jpg)
@@ -1,5 +1,5 @@
export const metadata = {
title: `Shipping Options`,
title: `Shipping Option`,
}
# {metadata.title}
@@ -12,21 +12,21 @@ A shipping option is a way of shipping an item. Each fulfillment provider provid
When the customer places their order, they choose a shipping option to be used to fulfill their items.
A shipping option is represented by the `ShippingOption` data model.
A shipping option is represented by the [ShippingOption data model](/references/fulfillment/models/ShippingOption).
---
## Service Zone Restrictions
A shipping option is restricted by a service zone, which specifies in what locations can a shipping option be used.
A shipping option is restricted by a service zone, limiting the locations a shipping option be used in.
For example, a fulfillment provider may have a shipping option that can be used in the United States, and another in Canada.
![https://res.cloudinary.com/dza7lstvk/image/upload/v1712330831/Medusa%20Resources/shipping-option-service-zone_pobh6k.jpg](https://res.cloudinary.com/dza7lstvk/image/upload/v1712330831/Medusa%20Resources/shipping-option-service-zone_pobh6k.jpg)
![A diagram showcasing the relation between shipping options and service zones.](https://res.cloudinary.com/dza7lstvk/image/upload/v1712330831/Medusa%20Resources/shipping-option-service-zone_pobh6k.jpg)
Service zones can be more restrictive, such as restricting to certain cities or province codes.
![https://res.cloudinary.com/dza7lstvk/image/upload/v1712331186/Medusa%20Resources/shipping-option-service-zone-city_m5sxod.jpg](https://res.cloudinary.com/dza7lstvk/image/upload/v1712331186/Medusa%20Resources/shipping-option-service-zone-city_m5sxod.jpg)
![A diagram showcasing the relation between shipping options, service zones, and geo zones](https://res.cloudinary.com/dza7lstvk/image/upload/v1712331186/Medusa%20Resources/shipping-option-service-zone-city_m5sxod.jpg)
---
@@ -34,26 +34,26 @@ Service zones can be more restrictive, such as restricting to certain cities or
You can restrict shipping options by custom rules, such as the items weight or the customers group.
These rules are represented by the `ShippingOptionRule` data model. Its fields define the custom rule:
These rules are represented by the [ShippingOptionRule data model](/references/fulfillment/models/ShippingOptionRule). Its fields define the custom rule:
- `field`: The name of an field or table that the rule applies to. For example, `customer_group`.
- `value`: One or more values.
- `attribute`: The name of a field or table that the rule applies to. For example, `customer_group`.
- `operator`: The operator used in the condition. For example:
- To allow multiple values, use the operator `in`, which validates that the provided values are in the rules values.
- To create a negation condition that considers `value` against the rule, use `nin`, which validates that the provided values arent in the rules values.
- Check out more operators in [this reference](/references/fulfillment/types/fulfillment.RuleOperatorType).
- `value`: One or more values.
![https://res.cloudinary.com/dza7lstvk/image/upload/v1712331340/Medusa%20Resources/shipping-option-rule_oosopf.jpg](https://res.cloudinary.com/dza7lstvk/image/upload/v1712331340/Medusa%20Resources/shipping-option-rule_oosopf.jpg)
![A diagram showcasing the relation between shipping option and shipping option rules.](https://res.cloudinary.com/dza7lstvk/image/upload/v1712331340/Medusa%20Resources/shipping-option-rule_oosopf.jpg)
A shipping option can have multiple rules. For example, a shipping option is available if the customer belongs to the VIP group and the total weight is less than 2000g.
![https://res.cloudinary.com/dza7lstvk/image/upload/v1712331462/Medusa%20Resources/shipping-option-rule-2_ylaqdb.jpg](https://res.cloudinary.com/dza7lstvk/image/upload/v1712331462/Medusa%20Resources/shipping-option-rule-2_ylaqdb.jpg)
![A diagram showcasing how a shipping option can have multiple rules.](https://res.cloudinary.com/dza7lstvk/image/upload/v1712331462/Medusa%20Resources/shipping-option-rule-2_ylaqdb.jpg)
---
## Shipping Profile and Types
A shipping option belongs to a type. For example, a shipping options type may be `express`, while another `standard`. The type is represented by the `ShippingOptionType` data model.
A shipping option belongs to a type. For example, a shipping options type may be `express`, while another `standard`. The type is represented by the [ShippingOptionType data model](/references/fulfillment/models/ShippingOptionType).
A shipping option also belongs to a shipping profile, as each shipping profile defines the type of items to be shipped in a similar manner.