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: string
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": [],
"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: object
The name of the discount.
items.version: number
The version of the discount.
items.identifier: string
The identifier of the discount.
items.type: string
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: Record<string, unknown>
The value of the discount.
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: object
The exclusions of the discount.
items.gifts: object
The gifts of the discount.
items.giftsReplaceCartItems: boolean
Whether the gifts replace cart items.
items.userGroups: object
The user groups of the discount.
items.userExclusions: object
The user exclusions of the discount.
items.attributeValues: object
The attribute values of the discount.
items.attributeSetIdentifier: string
The identifier of the attribute set.
total: number
Total number of discounts.