Files
medusa-store/www/apps/docs/content/references/entities/classes/Discount.mdx
Shahed Nasser c6dff873de docs: update docusaurus to v3 (#5625)
* update dependencies

* update onboarding mdx

* fixes for mdx issues

* fixes for mdx compatibility

* resolve mdx errors

* fixes in reference

* fix check errors

* revert change in vale action

* fix node version in action

* fix summary in markdown
2023-11-13 20:11:50 +02:00

604 lines
18 KiB
Plaintext

---
displayed_sidebar: entitiesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Discount
A discount can be applied to a cart for promotional purposes.
## Properties
<ParameterTypes parameters={[
{
"name": "code",
"type": "`string`",
"description": "A unique code for the discount - this will be used by the customer to apply the discount",
"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": "deleted_at",
"type": "``null`` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "ends_at",
"type": "``null`` \\| `Date`",
"description": "The time at which the discount can no longer be used.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The discount's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Whether the Discount has been disabled. Disabled discounts cannot be applied to carts",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_dynamic",
"type": "`boolean`",
"description": "A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts",
"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": "parent_discount",
"type": "[Discount](Discount.mdx)",
"description": "The details of the parent discount that this discount was created from.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "code",
"type": "`string`",
"description": "A unique code for the discount - this will be used by the customer to apply the discount",
"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": "deleted_at",
"type": "``null`` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "ends_at",
"type": "``null`` \\| `Date`",
"description": "The time at which the discount can no longer be used.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The discount's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Whether the Discount has been disabled. Disabled discounts cannot be applied to carts",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_dynamic",
"type": "`boolean`",
"description": "A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts",
"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": "parent_discount",
"type": "[Discount](Discount.mdx)",
"description": "The details of the parent discount that this discount was created from.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "parent_discount_id",
"type": "`string`",
"description": "The Discount that the discount was created from. This will always be a dynamic discount",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "regions",
"type": "[Region](Region.mdx)[]",
"description": "The details of the regions in which the Discount can be used.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "rule",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule that defines how the discount will be applied to a cart..",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "rule_id",
"type": "`string`",
"description": "The ID of the discount rule that defines how the discount will be applied to a cart.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "starts_at",
"type": "`Date`",
"description": "The time at which the discount can be used.",
"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": "usage_count",
"type": "`number`",
"description": "The number of times a discount has been used.",
"optional": false,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "usage_limit",
"type": "``null`` \\| `number`",
"description": "The maximum number of times that a discount can be used.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "valid_duration",
"type": "``null`` \\| `string`",
"description": "Duration the discount runs between",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "parent_discount_id",
"type": "`string`",
"description": "The Discount that the discount was created from. This will always be a dynamic discount",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "regions",
"type": "[Region](Region.mdx)[]",
"description": "The details of the regions in which the Discount can be used.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "automatic_taxes",
"type": "`boolean`",
"description": "Whether taxes should be automated in this region.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "countries",
"type": "[Country](Country.mdx)[]",
"description": "The details of the countries included in this region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](Currency.mdx)",
"description": "The details of the currency used in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "The three character currency code used in the region.",
"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": "fulfillment_providers",
"type": "[FulfillmentProvider](FulfillmentProvider.mdx)[]",
"description": "The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_cards_taxable",
"type": "`boolean`",
"description": "Whether the gift cards are taxable or not in this region.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The region's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Whether the prices for the region include tax",
"optional": false,
"defaultValue": "false",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_providers",
"type": "[PaymentProvider](PaymentProvider.mdx)[]",
"description": "The details of the payment providers that can be used to process payments in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_code",
"type": "`string`",
"description": "The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_provider",
"type": "[TaxProvider](TaxProvider.mdx)",
"description": "The details of the tax provider used in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_provider_id",
"type": "``null`` \\| `string`",
"description": "The ID of the tax provider used in this region",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rate",
"type": "`number`",
"description": "The tax rate that should be charged on purchases in the Region.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rates",
"type": "``null`` \\| [TaxRate](TaxRate.mdx)[]",
"description": "The details of the tax rates used in the region, aside from the default rate.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "rule",
"type": "[DiscountRule](DiscountRule.mdx)",
"description": "The details of the discount rule that defines how the discount will be applied to a cart..",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "allocation",
"type": "[AllocationType](../enums/AllocationType.mdx)",
"description": "The scope that the discount should apply to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "conditions",
"type": "[DiscountCondition](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": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "id",
"type": "`string`",
"description": "The discount rule's ID",
"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": "type",
"type": "[DiscountRuleType](../enums/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": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"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": "rule_id",
"type": "`string`",
"description": "The ID of the discount rule that defines how the discount will be applied to a cart.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "starts_at",
"type": "`Date`",
"description": "The time at which the discount can be used.",
"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": "usage_count",
"type": "`number`",
"description": "The number of times a discount has been used.",
"optional": false,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "usage_limit",
"type": "``null`` \\| `number`",
"description": "The maximum number of times that a discount can be used.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "valid_duration",
"type": "``null`` \\| `string`",
"description": "Duration the discount runs between",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />