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
20 KiB
Plaintext
15 lines
20 KiB
Plaintext
---
|
|
displayed_sidebar: entitiesSidebar
|
|
slug: /references/entities/classes/DiscountCondition
|
|
---
|
|
|
|
import TypeList from "@site/src/components/TypeList"
|
|
|
|
# DiscountCondition
|
|
|
|
Holds rule conditions for when a discount is applicable
|
|
|
|
## Properties
|
|
|
|
<TypeList types={[{"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":"PRODUCTS","type":"`\"products\"`","description":"The discount condition is used for products.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PRODUCT_TYPES","type":"`\"product_types\"`","description":"The discount condition is used for product types.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PRODUCT_COLLECTIONS","type":"`\"product_collections\"`","description":"The discount condition is used for product collections.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PRODUCT_TAGS","type":"`\"product_tags\"`","description":"The discount condition is used for product tags.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"CUSTOMER_GROUPS","type":"`\"customer_groups\"`","description":"The discount condition is used for customer groups.","optional":true,"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":"IN","type":"`\"in\"`","description":"The discountable resources are within the specified resources.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"NOT_IN","type":"`\"not_in\"`","description":"The discountable resources are everything but the specified resources.","optional":true,"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":"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":"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":"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":"metadata","type":"`Record<string, unknown>`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"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":"id","type":"`string`","description":"The product'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":"title","type":"`string`","description":"A title that can be displayed for easy identification of the Product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"An optional subtitle that can be used to further specify the Product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"A short description of the Product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`null` \\| `string`","description":"A unique identifier for the Product (e.g. for slug structure).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../enums/entities.ProductStatus.mdx)","description":"The status of the product","optional":false,"defaultValue":"draft","expandable":false,"children":[]},{"name":"images","type":"[Image](entities.Image.mdx)[]","description":"The details of the product's images.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"A URL to an image file that can be used to identify the Product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[ProductOption](entities.ProductOption.mdx)[]","description":"The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"variants","type":"[ProductVariant](entities.ProductVariant.mdx)[]","description":"The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"categories","type":"[ProductCategory](entities.ProductCategory.mdx)[]","description":"The details of the product categories that this product belongs to.","optional":false,"defaultValue":"","expandable":true,"featureFlag":"product_categories","children":[]},{"name":"profile_id","type":"`string`","description":"The ID of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"profile","type":"[ShippingProfile](entities.ShippingProfile.mdx)","description":"The details of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"profiles","type":"[ShippingProfile](entities.ShippingProfile.mdx)[]","description":"Available if the relation `profiles` is expanded.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the Product Variant. May be used in shipping rate calculations.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the Product Variant. May be used in shipping rate calculations.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the Product Variant. May be used in shipping rate calculations.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the Product Variant. May be used in shipping rate calculations.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"The ID of the product collection that the product belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"[ProductCollection](entities.ProductCollection.mdx)","description":"The details of the product collection that the product belongs to.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"The ID of the product type that the product belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ProductType](entities.ProductType.mdx)","description":"The details of the product type that the product belongs to.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"tags","type":"[ProductTag](entities.ProductTag.mdx)[]","description":"The details of the product tags used in this product.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"discountable","type":"`boolean`","description":"Whether the Product can be discounted. Discounts will not apply to Line Items of this Product when this flag is set to `false`.","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"external_id","type":"`null` \\| `string`","description":"The external ID of the product","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channels","type":"[SalesChannel](entities.SalesChannel.mdx)[]","description":"The details of the sales channels this product is available in.","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":"id","type":"`string`","description":"The product type'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":"value","type":"`string`","description":"The value that the Product Type represents.","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":[]}]},{"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":"id","type":"`string`","description":"The product tag'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":"value","type":"`string`","description":"The value that the Product Tag represents","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":[]}]},{"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":"id","type":"`string`","description":"The product collection'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":"title","type":"`string`","description":"The title that the Product Collection is identified by.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"A unique string that identifies the Product Collection - can for example be used in slug structures.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[Product](entities.Product.mdx)[]","description":"The details of the products that belong to this product collection.","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":"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":"id","type":"`string`","description":"The customer group'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":"name","type":"`string`","description":"The name of the customer group","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customers","type":"[Customer](entities.Customer.mdx)[]","description":"The details of the customers that belong to the customer group.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"price_lists","type":"[PriceList](entities.PriceList.mdx)[]","description":"The price lists that are associated with the customer group.","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="DiscountCondition"/>
|