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

@@ -18,7 +18,7 @@ A cart has a shipping and billing address. Both of these addresses are represent
A line item, represented by the `LineItem` data model, is a product variant added to the cart. A cart has multiple line items.
A line item stores some of the product variant’s fields, such as the `product_title` and `product_description`. It also stores data related to the item’s quantity and price.
A line item stores some of the product variant’s properties, such as the `product_title` and `product_description`. It also stores data related to the item’s quantity and price.
<Note>
@@ -36,8 +36,8 @@ If the shipping method is created from a shipping option, available through the
A shipping method can also be a custom method associated with this cart only.
### data Field
### data Property
After an order is placed, you may use a third-party fulfillment provider to fulfill its shipments. If the fulfillment provider requires additional custom data to be passed along from the checkout process, you can add this data in the `ShippingMethod`'s `data` field.
After an order is placed, you may use a third-party fulfillment provider to fulfill its shipments. If the fulfillment provider requires additional custom data to be passed along from the checkout process, you can add this data in the `ShippingMethod`'s `data` property.
The `data` field is an object used to store custom data relevant later for fulfillment.
The `data` property is an object used to store custom data relevant later for fulfillment.
@@ -25,7 +25,7 @@ In this guide, you’ll find common examples of how you can use the Cart Module
const cartModuleService: ICartModuleService =
req.scope.resolve(ModuleRegistrationName.CART)
const cart = await cartModuleService.create({
const cart = await cartModuleService.createCarts({
currency_code: "usd",
shipping_address: {
address_1: "1512 Barataria Blvd",
@@ -57,7 +57,7 @@ In this guide, you’ll find common examples of how you can use the Cart Module
export async function POST(request: Request) {
const cartModuleService = await initializeCartModule()
const cart = await cartModuleService.create({
const cart = await cartModuleService.createCarts({
currency_code: "usd",
shipping_address: {
address_1: "1512 Barataria Blvd",
@@ -100,7 +100,9 @@ In this guide, you’ll find common examples of how you can use the Cart Module
const cartModuleService: ICartModuleService =
req.scope.resolve(ModuleRegistrationName.CART)
const cart = await cartModuleService.retrieve("cart_123")
const cart = await cartModuleService.retrieveCart(
"cart_123"
)
res.json({ cart })
}
@@ -119,7 +121,9 @@ In this guide, you’ll find common examples of how you can use the Cart Module
export async function GET(request: Request) {
const cartModuleService = await initializeCartModule()
const cart = await cartModuleService.retrieve("cart_123")
const cart = await cartModuleService.retrieveCart(
"cart_123"
)
return NextResponse.json({
cart,
@@ -15,7 +15,7 @@ The Cart Module is the `@medusajs/cart` NPM package that provides cart-related f
Store and manage carts, including their addresses, line items, shipping methods, and more.
```ts
const cart = await cartModuleService.create({
const cart = await cartModuleService.createCarts({
currency_code: "usd",
shipping_address: {
address_1: "1512 Barataria Blvd",
@@ -76,7 +76,6 @@ For example:
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { res } from "express"
export async function GET(
req: MedusaRequest,
@@ -86,7 +85,7 @@ For example:
req.scope.resolve(ModuleRegistrationName.CART)
res.json({
carts: await cartModuleService.list(),
carts: await cartModuleService.listCarts(),
})
}
```
@@ -105,7 +104,7 @@ For example:
const cartModuleService: ICartModuleService =
container.resolve(ModuleRegistrationName.CART)
const carts = await cartModuleService.list()
const carts = await cartModuleService.listCarts()
}
```
@@ -125,7 +124,7 @@ For example:
ModuleRegistrationName.CART
)
const carts = await cartModuleService.list()
const carts = await cartModuleService.listCarts()
})
```
@@ -18,13 +18,13 @@ The `LineItemAdjustment` data model represents changes on a line item, and the `
![A diagram showcasing the relations between other data models and adjustment line models](https://res.cloudinary.com/dza7lstvk/image/upload/v1711534248/Medusa%20Resources/cart-adjustments_k4sttb.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 is 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 is 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.
@@ -50,7 +50,7 @@ import {
} from "@medusajs/types"
// retrieve the cart
const cart = await cartModuleService.retrieve("cart_123", {
const cart = await cartModuleService.retrieveCart("cart_123", {
relations: [
"items.adjustments",
"shipping_methods.adjustments",
@@ -18,7 +18,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 added 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.
@@ -38,7 +38,7 @@ When using the Cart and Tax modules together, you can use the `getTaxLines` meth
```ts
// retrieve the cart
const cart = await cartModuleService.retrieve("cart_123", {
const cart = await cartModuleService.retrieveCart("cart_123", {
relations: [
"items.tax_lines",
"shipping_methods.tax_lines",