Chuyển đến nội dung chính

getAllDiscounts

Lấy tất cả các đối tượng giảm giá.

Description

Phương thức này truy xuất các đối tượng giảm giá với phân trang và bộ lọc loại tùy chọn. Nó trả về một Promise mà khi hoàn thành sẽ trả về một đối tượng IDiscountsResponse chứa các mục và tổng số lượng.

Giảm giá.getAllDiscounts(

langCode, offset, limit, type

);

Parameters schema

Schema

langCode: string
Mã ngôn ngữ. Mặc định: "en_US"
ví dụ: "en_US"

offset: number
Tham số tùy chọn cho phân trang. Mặc định: 0
ví dụ: 0

limit: number
Tham số tùy chọn cho phân trang. Mặc định: 30
ví dụ: 30

type: IDiscountType
Tham số tùy chọn để lọc giảm giá theo loại

Mặc định, bạn có thể truy xuất 10 đối tượng. Điều này là do giới hạn bản ghi trong cài đặt quyền của mô-đun.
Để phân trang hoạt động chính xác, bạn cần cấu hình Quyền mô-đun theo nhu cầu của bạn trong phần tương ứng.

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
},
{
"id": 2,
"type": "PERSONAL_DISCOUNT",
"attributeSetId": null,
"conditionLogic": "AND",
"discountValue": {
"value": 15,
"maxAmount": null,
"discountType": "FIXED_AMOUNT",
"applicability": "TO_ORDER"
},
"exclusions": null,
"gifts": null,
"giftsReplaceCartItems": false,
"userGroups": null,
"userExclusions": null,
"localizeInfos": {
"title": "Personal discount"
},
"version": 2,
"identifier": "personal_discount",
"startDate": "2026-04-21T18:26:19.815Z",
"endDate": "2028-03-21T19:26:24.741Z",
"attributeValues": {},
"conditions": [],
"bonusEvent": null,
"position": 2
}
],
"total": 2
}

Response schema

Schema: IDiscountEntity[]

items: IDiscountsEntity[]
Mảng các thực thể giảm giá.

items.id: number
Định danh duy nhất của giảm giá.

items.attributeSetId: number
Định danh của giảm giá.

items.localizeInfos: ILocalizeInfo
Tên của giảm giá.

items.version: number
Phiên bản của giảm giá.

items.identifier: string
Định danh của giảm giá.

items.type: IDiscountType
Loại của giảm giá.

items.startDate: string
Ngày bắt đầu của giảm giá.

items.endDate: string
Ngày kết thúc của giảm giá.

items.discountValue: IDiscountValue
Giá trị của giảm giá, bao gồm loại và giới hạn số tiền.

items.conditionLogic: string
Logic của giảm giá. Các giá trị có thể là "AND" | "OR".

items.conditions: IDiscountCondition[]
Các điều kiện của giảm giá.

items.exclusions: Record<string, unknown> | null
Các loại trừ của giảm giá.

items.gifts: Record<string, unknown> | null
Các món quà của giảm giá.

items.giftsReplaceCartItems: boolean
Liệu các món quà có thay thế các mục trong giỏ hàng hay không.

items.userGroups: Record<string, unknown> | null
Các nhóm người dùng của giảm giá.

items.userExclusions: Record<string, unknown> | null
Các loại trừ người dùng của giảm giá.

items.attributeValues: IAttributeValues
Các giá trị thuộc tính của giảm giá.

items.attributeSetIdentifier: string
Định danh của bộ thuộc tính.

items.bonusEvent: Record<string, unknown>
Cấu hình sự kiện thưởng.

items.position: number
Số thứ tự để sắp xếp.
ví dụ: 1

items.total: number | string
Tổng số lượng các mục liên quan.
ví dụ: "1"

total: number
Tổng số lượng giảm giá.