This PR includes documentation that preps for v2 docs (but doesn't introduce new docs). _Note: The number of file changes in the PR is due to find-and-replace within the `references` which is unavoidable. Let me know if I should move it to another PR._ ## Changes - Change Medusa version in base OAS used for v2. - Fix to docblock generator related to not catching all path parameters. - Added typedoc plugin that generates ER Diagrams, which will be used specifically for data model references in commerce modules. - Changed OAS tool to output references in `www/apps/api-reference/specs-v2` directory when the `--v2` option is used. - Added a version switcher to the API reference to switch between V1 and V2. This switcher is enabled by an environment variable, so it won't be visible/usable at the moment. - Upgraded docusaurus to v3.0.1 - Added new Vale rules to ensure correct spelling of Medusa Admin and module names. - Added new components to the `docs-ui` package that will be used in future documentation changes.
15 lines
6.6 KiB
Plaintext
15 lines
6.6 KiB
Plaintext
---
|
|
displayed_sidebar: entitiesSidebar
|
|
slug: /references/entities/classes/DiscountRule
|
|
---
|
|
|
|
import TypeList from "@site/src/components/TypeList"
|
|
|
|
# DiscountRule
|
|
|
|
A discount rule defines how a Discount is calculated when applied to a Cart.
|
|
|
|
## Properties
|
|
|
|
<TypeList types={[{"name":"id","type":"`string`","description":"The discount rule's ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"A short description of the discount","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[DiscountRuleType](../enums/entities.DiscountRuleType.mdx)","description":"The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free\\_shipping` for shipping vouchers.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"FIXED","type":"`\"fixed\"`","description":"Discounts that reduce the price by a fixed amount.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PERCENTAGE","type":"`\"percentage\"`","description":"Discounts that reduce the price by a percentage reduction.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"FREE_SHIPPING","type":"`\"free_shipping\"`","description":"Discounts that sets the shipping price to `0`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"value","type":"`number`","description":"The value that the discount represents; this will depend on the type of the discount","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allocation","type":"[AllocationType](../enums/entities.AllocationType.mdx)","description":"The scope that the discount should apply to.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"TOTAL","type":"`\"total\"`","description":"The discount should be applied to the checkout total.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ITEM","type":"`\"item\"`","description":"The discount should be applied to applicable items in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"conditions","type":"[DiscountCondition](entities.DiscountCondition.mdx)[]","description":"The details of the discount conditions associated with the rule. They can be used to limit when the discount can be used.","optional":false,"defaultValue":"","expandable":true,"children":[{"name":"id","type":"`string`","description":"The discount condition's ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[DiscountConditionType](../enums/entities.DiscountConditionType.mdx)","description":"The type of the condition. The type affects the available resources associated with the condition. For example, if the type is `products`, that means the `products` relation will hold the products associated with this condition and other relations will be empty.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"operator","type":"[DiscountConditionOperator](../enums/entities.DiscountConditionOperator.mdx)","description":"The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not\\_in` indicates that discountable resources are everything but the specified resources.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_rule_id","type":"`string`","description":"The ID of the discount rule associated with the condition","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_rule","type":"[DiscountRule](entities.DiscountRule.mdx)","description":"The details of the discount rule associated with the condition.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"products","type":"[Product](entities.Product.mdx)[]","description":"products associated with this condition if `type` is `products`.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"product_types","type":"[ProductType](entities.ProductType.mdx)[]","description":"Product types associated with this condition if `type` is `product\\_types`.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"product_tags","type":"[ProductTag](entities.ProductTag.mdx)[]","description":"Product tags associated with this condition if `type` is `product\\_tags`.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"product_collections","type":"[ProductCollection](entities.ProductCollection.mdx)[]","description":"Product collections associated with this condition if `type` is `product\\_collections`.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"customer_groups","type":"[CustomerGroup](entities.CustomerGroup.mdx)[]","description":"Customer groups associated with this condition if `type` is `customer\\_groups`.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/development/entities/repositories#retrieving-a-list-of-records" sectionTitle="DiscountRule"/>
|