docs: updates to use DML and other changes (#7834)

- Change existing data model guides and add new ones for DML
- Change module's docs around service factory + remove guides that are now necessary
- Hide/remove all mentions of module relationships, or label them as coming soon.
- Change all data model creation snippets to use DML
- use `property` instead of `field` when referring to a data model's properties.
- Fix all snippets in commerce module guides to use new method suffix (no more main model methods)
- Rework recipes, removing/hiding a lot of sections as a lot of recipes are incomplete with the current state of DML.


### Other changes

- Highlight fixes in some guides
- Remove feature flags guide
- Fix code block styles when there are no line numbers.

### Upcoming changes in other PRs

- Re-generate commerce module references (for the updates in the method names)
- Ensure that the data model references are generated correctly for models using DML.
- (probably at a very later point) revisit recipes
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-06-26 07:55:59 +00:00
1 parent 62dacdda75
commit 0462cc5acf
126 files changed
+1808 -14242

No files matched your search

@@ -22,13 +22,13 @@ The details of the purchased products are represented by the [LineItem data mode
An order has one or more shipping methods used to handle item shipment. Each shipping method is represented by the [ShippingMethod data model](/references/order/models/ShippingMethod) that holds its details.
### data Field
### data Property
When fulfilling the order, you may use a third-party fulfillment provider that requires additional custom data to be passed along from the order creation process.
The `ShippingMethod` data model has a `data` field. It’s an object used to store custom data relevant later for fulfillment.
The `ShippingMethod` data model has a `data` property. It’s an object used to store custom data relevant later for fulfillment.
The Medusa application passes the `data` field to the Fulfillment Module when fulfilling items.
The Medusa application passes the `data` property to the Fulfillment Module when fulfilling items.
---
@@ -35,7 +35,7 @@ Each of these actions is represented by the [OrderChangeAction data model](/refe
### Action Name
The `action` field of the `OrderChangeAction` holds the name of the action to perform. Based on the action, additional details are stored in the `details` object field of the data model.
The `action` property of the `OrderChangeAction` holds the name of the action to perform. Based on the action, additional details are stored in the `details` object property of the data model.
<Table>
<Table.Header>
@@ -162,7 +162,7 @@ The `action` field of the `OrderChangeAction` holds the name of the action to pe
Mark as received an item whose return was previously requested, but consider the items damaged.
This changes the order item’s `return_dismissed_quantity` field rather than its `return_received_quantity` field.
This changes the order item’s `return_dismissed_quantity` property rather than its `return_received_quantity` property.
</Table.Cell>
<Table.Cell>
@@ -223,7 +223,7 @@ The `action` field of the `OrderChangeAction` holds the name of the action to pe
</Table.Cell>
<Table.Cell>
Mark a quantity of an item as shipped. This modifies the shipped_quantity field of an order item.
Mark a quantity of an item as shipped. This modifies the `shipped_quantity` property of an order item.
</Table.Cell>
<Table.Cell>
@@ -243,7 +243,7 @@ The `action` field of the `OrderChangeAction` holds the name of the action to pe
</Table.Cell>
<Table.Cell>
Mark a quantity of an item as fulfilled. This modifies the fulfilled_quantity field of an order item.
Mark a quantity of an item as fulfilled. This modifies the `fulfilled_quantity` property of an order item.
</Table.Cell>
<Table.Cell>
@@ -277,7 +277,7 @@ The `action` field of the `OrderChangeAction` holds the name of the action to pe
## Order Change Confirmation
The `OrderChange` data model has a `status` field that indicates its current status. By default, it’s pending. At this point, the order change’s actions aren’t applied to the order yet.
The `OrderChange` data model has a `status` property that indicates its current status. By default, it’s pending. At this point, the order change’s actions aren’t applied to the order yet.
To apply these changes to the order, you confirm the order change. When the order change is confirmed:
@@ -12,17 +12,17 @@ Versioning means assigning a version number to a record, such as an order and it
---
## version Field
## version Property
The `Order` and `OrderSummary` data models have a `version` field that indicates the current order version. By default, its value is `1`.
The `Order` and `OrderSummary` data models have a `version` property that indicates the current order version. By default, its value is `1`.
The `OrderItem` data model also has a `version` field, but it indicates the version it belongs to. For example, original items in the order have version `1`. Then, when a new item is added, its version is `2`. If an existing item is modified, such as its quantity has been changed, its version is updated.
The `OrderItem` data model also has a `version` property, but it indicates the version it belongs to. For example, original items in the order have version `1`. Then, when a new item is added, its version is `2`. If an existing item is modified, such as its quantity has been changed, its version is updated.
---
## Order Change Versioning
The `OrderChange` and `OrderChangeAction` data models also have a `version` field. When an order change is created, the `version` field’s value is the associated order’s version incremented.
The `OrderChange` and `OrderChangeAction` data models also have a `version` property. When an order change is created, the `version` property’s value is the associated order’s version incremented.
So, if the order’s `version` is `1`, the order change’s version is `2`.
@@ -15,7 +15,7 @@ The Order Module is the `@medusajs/order` NPM package that provides order-relate
Store and manage your orders to retriev, create, cancel, and perform other operations.
```ts
const order = await orderModuleService.create({
const order = await orderModuleService.createOrders({
currency_code: "usd",
items: [
{
@@ -38,7 +38,7 @@ const order = await orderModuleService.create({
Allow merchants to create orders on behalf of their customers as draft orders that later are transformed to regular orders.
```ts
const draftOrder = await orderModuleService.create({
const draftOrder = await orderModuleService.createOrders({
currency_code: "usd",
// other details...
status: "draft",
@@ -122,7 +122,7 @@ For example:
req.scope.resolve(ModuleRegistrationName.ORDER)
res.json({
orders: await orderModuleService.list(),
orders: await orderModuleService.listOrders(),
})
}
```
@@ -141,7 +141,7 @@ For example:
const orderModuleService: IOrderModuleService =
container.resolve(ModuleRegistrationName.ORDER)
const orders = await orderModuleService.list()
const orders = await orderModuleService.listOrders()
}
```
@@ -160,7 +160,7 @@ For example:
container.resolve(
ModuleRegistrationName.ORDER
)
const orders = await orderModuleService.list()
const orders = await orderModuleService.listOrders()
})
```
@@ -18,13 +18,13 @@ The [LineItemAdjustment data model](/references/order/models/LineItemAdjustment)
![A diagram showcasing the relation between an order, its items and shipping methods, and their adjustment lines](https://res.cloudinary.com/dza7lstvk/image/upload/v1712306017/Medusa%20Resources/order-adjustments_myflir.jpg)
The `amount` field of the adjustment line indicates the amount to be discounted from the original amount. Also, the ID of the applied promotion can be stored in the `promotion_id` field of the adjustment line.
The `amount` property of the adjustment line indicates the amount to be discounted from the original amount. Also, the ID of the applied promotion can be stored in the `promotion_id` property of the adjustment line.
---
## Discountable Option
The `LineItem` data model has an `is_discountable` field that indicates whether promotions can be applied to the line item. It’s enabled by default.
The `LineItem` data model has an `is_discountable` property that indicates whether promotions can be applied to the line item. It’s enabled by default.
When disabled, a promotion can’t be applied to a line item. In the context of the Promotion Module, the promotion isn’t applied to the line item even if it matches its rules.
@@ -52,7 +52,7 @@ import {
// ...
// retrieve the order
const order = await orderModuleService.retrieve("ord_123", {
const order = await orderModuleService.retrieveOrder("ord_123", {
relations: [
"items.item.adjustments",
"shipping_methods.adjustments",
@@ -22,7 +22,7 @@ A tax line indicates the tax rate of a line item or a shipping method. The [Line
By default, the tax amount is calculated by taking the tax rate from the line item or shipping method’s amount and then adding it to the item/method’s subtotal.
However, line items and shipping methods have an `is_tax_inclusive` field that, when enabled, indicates that the item or method’s price already includes taxes.
However, line items and shipping methods have an `is_tax_inclusive` property that, when enabled, indicates that the item or method’s price already includes taxes.
So, instead of calculating the tax rate and adding it to the item/method’s subtotal, it’s calculated as part of the subtotal.
@@ -18,7 +18,7 @@ The transaction’s main purpose is to ensure a correct balance between paid and
## Checking Outstanding Amount
The order’s total is stored in the `OrderSummary`'s `total` field. To check the outstanding amount of the order, its transaction amounts are summed. Then, the following conditions are checked:
The order’s total is stored in the `OrderSummary`'s `total` property. To check the outstanding amount of the order, its transaction amounts are summed. Then, the following conditions are checked:
<Table>
<Table.Header>
@@ -73,7 +73,7 @@ The order’s total is stored in the `OrderSummary`'s `total` field. To check th
The Order Module doesn’t provide payment processing functionalities, so it doesn’t store payments that can be processed. For that, use the Payment Module or custom logic.
The `Transaction` data model has two fields that determine which data model and record holds the actual payment’s details:
The `Transaction` data model has two properties that determine which data model and record holds the actual payment’s details:
- `reference`: indicates the table’s name in the database. For example, `payment` if you’re using the Payment Module.
- `reference_id`: indicates the ID of the record in the table. For example, `pay_123`.