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
2024-06-26 07:55:59 +00:00
committed by GitHub
parent 62dacdda75
commit 0462cc5acf
126 changed files with 1808 additions and 14242 deletions
@@ -18,7 +18,7 @@ A [PriceSet](/references/pricing/models/PriceSet) represents a collection of pri
Each price within a price set can be applied for different conditions. These conditions are represented as rule types.
A [RuleType](/references/pricing/models/RuleType) defines custom conditions. A rule type has a unique `rule_attribute` which indicates the field this rule applies on. For example, `region_id`.
A [RuleType](/references/pricing/models/RuleType) defines custom conditions. A rule type has a unique `rule_attribute` which indicates the property this rule applies on. For example, `region_id`.
This is referenced when setting a rule of a price. For example:
@@ -46,6 +46,6 @@ const priceSet = await pricingModuleService.addPrices({
## Price List
A [PriceList](/references/pricing/models/PriceList) is a group of prices only enabled if their conditions and rules are satisfied. A price list has optional `start_date` and `end_date` fields, which indicate the date range in which a price list can be applied.
A [PriceList](/references/pricing/models/PriceList) is a group of prices only enabled if their conditions and rules are satisfied. A price list has optional `start_date` and `end_date` properties, which indicate the date range in which a price list can be applied.
Its associated prices are represented by the `Price` data model.
@@ -27,7 +27,7 @@ In this document, youll find common examples of how you can use the Pricing M
// A rule type with \`rule_field=region_id\` should
// already be present in the database
const priceSet = await pricingModuleService.create([
const priceSet = await pricingModuleService.createPriceSets([
{
rules: [{ rule_field: "region_id" }],
prices: [
@@ -62,7 +62,7 @@ In this document, youll find common examples of how you can use the Pricing M
// A rule type with \`rule_field=region_i\` should
// already be present in the database
const priceSet = await pricingModuleService.create([
const priceSet = await pricingModuleService.createPriceSets([
{
rules: [{ rule_field: "region_id" }],
prices: [
@@ -103,7 +103,7 @@ In this document, youll find common examples of how you can use the Pricing M
const pricingModuleService: IPricingModuleService =
request.scope.resolve(ModuleRegistrationName.PRICING)
const priceSets = await pricingModuleService.list()
const priceSets = await pricingModuleService.listPriceSets()
res.json({ price_sets: priceSets })
}
@@ -122,7 +122,7 @@ In this document, youll find common examples of how you can use the Pricing M
export async function GET(request: Request) {
const pricingModuleService = await initializePricingModule()
const priceSets = await pricingModuleService.list()
const priceSets = await pricingModuleService.listPriceSets()
return NextResponse.json({ price_sets: priceSets })
}
@@ -150,7 +150,7 @@ In this document, youll find common examples of how you can use the Pricing M
const pricingModuleService: IPricingModuleService =
request.scope.resolve(ModuleRegistrationName.PRICING)
const priceSet = await pricingModuleService.retrieve(
const priceSet = await pricingModuleService.retrievePriceSet(
request.params.id
)
@@ -180,7 +180,7 @@ In this document, youll find common examples of how you can use the Pricing M
) {
const pricingModuleService = await initializePricingModule()
const priceSet = await pricingModuleService.retrieve(
const priceSet = await pricingModuleService.retrievePriceSet(
params.id
)
@@ -17,7 +17,7 @@ With the Pricing Module, store the prices of a resource and manage them through
Prices are grouped in a price set, allowing you to add more than one price for a resource based on different conditions, such as currency code.
```ts
const priceSet = await pricingModuleService.create({
const priceSet = await pricingModuleService.createPriceSets({
rules: [],
prices: [
{
@@ -124,7 +124,7 @@ For example:
request.scope.resolve(ModuleRegistrationName.PRICING)
res.json({
price_sets: await pricingModuleService.list(),
price_sets: await pricingModuleService.listPriceSets(),
})
}
```
@@ -143,7 +143,7 @@ For example:
const pricingModuleService: IPricingModuleService =
container.resolve(ModuleRegistrationName.PRICING)
const priceSets = await pricingModuleService.list()
const priceSets = await pricingModuleService.listPriceSets()
}
```
@@ -161,7 +161,7 @@ For example:
const pricingModuleService: IPricingModuleService =
container.resolve(ModuleRegistrationName.PRICING)
const priceSets = await pricingModuleService.list()
const priceSets = await pricingModuleService.listPriceSets()
})
```
@@ -178,7 +178,7 @@ const ruleTypes = await pricingModuleService.createRuleTypes([
},
])
const priceSet = await pricingModuleService.create({
const priceSet = await pricingModuleService.createPriceSets({
rules: [
{ rule_attribute: "region_id" },
{ rule_attribute: "city" },
@@ -422,7 +422,7 @@ const priceSet = await pricingModuleService.create({
<TabsContent value="code">
```ts
const priceList = pricingModuleService.createPriceList({
const priceList = pricingModuleService.createPriceLists({
name: "Test Price List",
starts_at: Date.parse("01/10/2023"),
ends_at: Date.parse("31/10/2023"),
@@ -8,7 +8,7 @@ In this document, you'll learn about price rules for price sets and price lists.
## Price Rule
Each rule of a price within a price set is represented by the [PriceRule data model](/references/pricing/models/PriceRule), which holds the value of a rule type. The `Price` data model has a `rules_count` field, which indicates how many rules, represented by `PriceRule`, are applied to the price.
Each rule of a price within a price set is represented by the [PriceRule data model](/references/pricing/models/PriceRule), which holds the value of a rule type. The `Price` data model has a `rules_count` property, which indicates how many rules, represented by `PriceRule`, are applied to the price.
![A diagram showcasing the relation between the PriceRule, PriceSet, Price, and RuleType.](https://res.cloudinary.com/dza7lstvk/image/upload/v1709648772/Medusa%20Resources/price-rule-1_vy8bn9.jpg)
@@ -40,7 +40,7 @@ For example, to use the `zip_code` rule type on a price in a price set, the rule
## Price List Rules
Rules that can be applied to a price list are represented by the [PriceListRule data model](/references/pricing/models/PriceListRule). The `rules_count` field of a `PriceList` indicates how many rules are applied to it.
Rules that can be applied to a price list are represented by the [PriceListRule data model](/references/pricing/models/PriceListRule). The `rules_count` property of a `PriceList` indicates how many rules are applied to it.
Each rule of a price list can have more than one value, representing its values by the [PriceListRuleValue data model](/references/pricing/models/PriceListRuleValue).