Files
medusa-store/www/apps/docs/content/references/services/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

207 lines
4.9 KiB
Plaintext

---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Discount
A discount can be applied to a cart for promotional purposes.
## Constructors
### constructor
`**new 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": "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": []
}
]} />
## Methods
### upperCaseCodeAndTrim
`Private **upperCaseCodeAndTrim**(): void`
#### Returns
`void`
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />