getAllDiscounts
Getting all discount objects.
Description
This method retrieves all discount objects. The method will add the default language to the request body. If you want to change the language, just pass it with the first argument. It returns a Promise that resolves to an array of IDiscountEntity objects.
Discounts.getAllDiscounts(
langCode,
offset,
limit,
type
);
Parameters schema
Schema
langCode: string
Language code. Default: "en_US"
example: "en_US"
offset: number
Optional parameter for pagination. Default: 0
example: 0
limit: number
Optional parameter for pagination. Default: 30
example: 30
type: IDiscountType
Optional parameter to filter discounts by type
By default, you can retrieve 10 objects. This is due to the record limit in the module's permissions settings.
For pagination to work correctly, you need to configure Module permissions according to your needs in the corresponding section.
Examples
Minimal example
const response = await Discounts.getAllDiscounts();
Example with attributes
const response = await Discounts.getAllDiscounts('en_US', 0, 30);
Example response
{
"items": [
{
"id": 1,
"type": "DISCOUNT",
"attributeSetId": 31,
"conditionLogic": "AND",
"discountValue": {
"value": 10,
"maxAmount": 5,
"discountType": "FIXED_AMOUNT",
"applicability": "TO_PRODUCT"
},
"exclusions": null,
"gifts": null,
"giftsReplaceCartItems": false,
"userGroups": null,
"userExclusions": null,
"localizeInfos": {
"title": "Example discount"
},
"version": 0,
"identifier": "example_discount",
"startDate": "2026-03-14T14:55:19.928Z",
"endDate": "2026-07-31T13:55:24.647Z",
"attributeValues": {
"example_discount": {
"type": "string",
"value": "test value",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
}
},
"conditions": [],
"bonusEvent": null,
"position": 1
}
],
"total": 1
}
Response schema
Schema: IDiscountEntity[]
items: IDiscountsEntity[]
Array of discount entities.
items.id: number
The unique identifier of the discount.
items.attributeSetId: number
The identifier of the discount.
items.localizeInfos: ILocalizeInfo
The name of the discount.
items.version: number
The version of the discount.
items.identifier: string
The identifier of the discount.
items.type: IDiscountType
The type of the discount.
items.startDate: string
The start date of the discount.
items.endDate: string
The end date of the discount.
items.discountValue: IDiscountValue
The value of the discount, including its type and amount limits.
discountValue.applicability: 'TO_PRODUCT' | 'TO_ORDER'
What the discount applies to.
example: "TO_PRODUCT"
discountValue.discountType: 'FIXED_AMOUNT' | 'PERCENT'
How the discount value is interpreted.
example: "FIXED_AMOUNT"
discountValue.value: number
Discount amount (currency units for FIXED_AMOUNT, percentage points for PERCENT).
example: 10
discountValue.maxAmount: number
Optional cap on the absolute discount applied.
example: 5
items.conditionLogic: string
The logic of the discount. Possible values are "AND" | "OR".
items.conditions: IDiscountCondition[]
The conditions of the discount.
conditions.type: string
The type of discount condition.
conditions.value: string
The value associated with the discount condition.
items.exclusions: Record<string, unknown> | null
The exclusions of the discount.
items.gifts: Record<string, unknown> | null
The gifts of the discount.
items.giftsReplaceCartItems: boolean
Whether the gifts replace cart items.
items.userGroups: Record<string, unknown> | null
The user groups of the discount.
items.userExclusions: Record<string, unknown> | null
The user exclusions of the discount.
items.attributeValues: IAttributeValues
The attribute values of the discount.
items.attributeSetIdentifier: string
The identifier of the attribute set.
items.bonusEvent: Record<string, unknown>
Bonus event configuration.
items.position: number
Position number for sorting.
example: 1
items.total: number | string
Total count of related entries.
example: "1"
total: number
Total number of discounts.