انتقل إلى المحتوى الرئيسي

getAllDiscounts

الحصول على جميع الخصومات.

الوصف​

يجلب الخصومات مع التقسيم إلى صفحات ومرشّح type اختياري. يُعيد IDiscountsResponse: الخصومات في items، والعدد في total.

.getAllDiscounts(

, , ,

);

مخطط المعلمات​

المخطط

langCode: string
رمز اللغة. الافتراضي: langCode المُمرَّر إلى defineOneEntry ("en_US" إذا لم يُمرَّر).
مثال: "en_US"

offset: number
عدد السجلات المراد تخطيها. الافتراضي: 0. يجب ألا يتجاوز offset + limit القيمة 200؛ وتُرفض النافذة الأكبر بالخطأ 400.
مثال: 0

limit: number
الحد الأقصى لعدد السجلات المراد إرجاعها. الافتراضي: 30.
مثال: 30

type: IDiscountType
نوع الخصم للتصفية: DISCOUNT أو BONUS أو PERSONAL_DISCOUNT.

حد السجلات. إذا كانت صلاحية مجموعة المستخدمين لهذه الطريقة تسمح بالقراءة المقيدة فقط، تُرجع واجهة API عددًا من السجلات لا يتجاوز العدد المحدد في إعدادات المشروع (10 افتراضيًا)، أيًّا كانت قيمة limit التي تمررها. مع صلاحية القراءة الكاملة يعمل limit كالمعتاد. راجع Module permissions (يفتح في علامة تبويب جديدة).

أمثلة​

مثال بسيط​

const response = await Discounts.getAllDiscounts();

مثال مع معلمات اختيارية​

const response = await Discounts.getAllDiscounts('en_US', 0, 30);

مثال على الاستجابة​

{
"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
}

مخطط الاستجابة​

المخطط: IDiscountsResponse

items: IDiscountsEntity[]
الخصومات في هذه الاستجابة.

items.id: number
معرّف الخصم.

items.attributeSetId: number | null
معرّف مجموعة السمات المرتبطة بالخصم، أو null إذا لم تُرتبط أي مجموعة.

items.localizeInfos: ILocalizeInfo
الاسم المترجم للخصم.

items.version: number
رقم إصدار الخصم.

items.identifier: string
علامة الخصم.

items.type: IDiscountType
نوع الخصم.

items.startDate: string
تاريخ بدء الخصم.

items.endDate: string
تاريخ انتهاء الخصم.

items.discountValue: IDiscountValue
قيمة الخصم مع نوعها وحدود المبلغ.

items.conditionLogic: string
طريقة دمج الشروط: AND أو OR.

items.conditions: IDiscountCondition[]
شروط الخصم.

items.exclusions: Record<string, unknown> | null
استثناءات الخصم.

items.gifts: Record<string, unknown> | null
هدايا الخصم.

items.giftsReplaceCartItems: boolean
ما إذا كانت الهدايا تحل محل عناصر السلة.

items.userGroups: Record<string, unknown> | null
مجموعات المستخدمين التي ينطبق عليها الخصم.

items.userExclusions: Record<string, unknown> | null
المستخدمون المستبعدون من الخصم.

items.attributeValues: IAttributeValues
قيم سمات الخصم.

items.attributeSetIdentifier: string
علامة مجموعة السمات.

items.bonusEvent: Record<string, unknown>
تكوين حدث المكافأة.

items.position: number
الموضع المستخدم للفرز.
مثال: 1

items.total: number | string
عدد صفوف داخلي يُرجعه API عن طريق الخطأ ("1" لخصم واحد). لا تعتمد عليه.
مثال: "1"

items.distance: number
مسافة جيب التمام إلى الاستعلام. تُرجعها نقطة نهاية البحث الدلالي (المتجهي) في كل عنصر.
مثال: 0.12

total: number
العدد الإجمالي للخصومات.