2c5ba408d4
Apply edits and fixes to the commerce modules docs
48 lines
2.8 KiB
Plaintext
48 lines
2.8 KiB
Plaintext
export const metadata = {
|
|
title: `Price Rules`,
|
|
}
|
|
|
|
# {metadata.title}
|
|
|
|
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.
|
|
|
|

|
|
|
|
For example, you create a `zip_code` rule type. Then, a price within the price set can have the rule value `10557`, indicating that the price can only be applied within the `10557` zip code.
|
|
|
|
Each price within the price set can have different values for the same rule type.
|
|
|
|
For example:
|
|
|
|

|
|
|
|
Each price can have multiple rules applied to it as well.
|
|
|
|
For example, a price can have the rules `zip_code` and `region_id` applied to it. In this case, the value of each rule is represented by a `PriceRule`.
|
|
|
|

|
|
|
|
---
|
|
|
|
## Restrict Price Rules
|
|
|
|
The [PriceSetRuleType data model](/references/pricing/models/PriceSetRuleType) indicates what rules the prices can have within a price set. It creates a relation between the `PriceSet` and `RuleType` data models.
|
|
|
|
For example, to use the `zip_code` rule type on a price in a price set, the rule type must first be enabled on the price set through the `PriceSetRuleType`.
|
|
|
|

|
|
|
|
---
|
|
|
|
## 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.
|
|
|
|
Each rule of a price list can have more than one value, representing its values by the [PriceListRuleValue data model](/references/pricing/models/PriceListRuleValue).
|
|
|
|

|