Skip to main content

Check potential discounts

There are situations where you would want to check potential discounts for an order, a product or a set of products. We can do so using PrefigureDiscounts.

Example request:

{
"codes": [
{
"code": "{\n \"OrderID\": 1,\n \"ProductIDs\": [1, 2, 3, 4],\n \"ProductSearchID\": 2,\n \"ProductSearch\": {}\n}",
"language": "json",
"name": "Request"
},
{
"code": "{\n \"Results\": [\n {\n \"DiscountID\": 1,\n \"BackendID\": \"DiscountBackendID\",\n \"Description\": \"DiscountDescription\",\n \"MarketingDescription\": \"DiscountMarketingDescription\",\n \"EligibleProductIDs\": [1, 2, 3, 4],\n \"IsAlreadyApplied\": false,\n \"RequirementsMet\": false,\n \"RequiresCustomer\": false,\n \"RequiresCustomerCustomData\": false,\n \"RequiresMinimumAmount\": false,\n \"RequiresCoupon\": false,\n \"CouponPresent\": false,\n \"ActionResult\": {},\n \"ConditionsResults\": [\n {}\n ]\n }\n ]\n}",
"language": "json",
"name": "Response"
}
]
}

The service request requires at least one of the properties to be set.

When OrderID is set, the discount engine will prefigure discounts based on the order, which includes the customer, possible coupons, ordertype etc. When OrderID is left empty, the engine will assume the order is a sales order and will try to use the current logged-in user to check for possible discounts.

EligibleProductIDs

When ProductIDs, ProductSearchID or ProductSearch is set in the request, the resulting products will be checked against the discount and all products that are eligible for the discount are returned in this list. This does not take in account if the order matches the conditions or action, but merely that the product could receive discount if all conditions are met.

{
"data": {
"0-0": "IsAlreadyApplied",
"1-0": "RequirementsMet",
"2-0": "RequiresCustomer",
"3-0": "RequiresCustomerCustomData",
"4-0": "RequiresMinimumAmount",
"5-0": "RequiresCoupon",
"6-0": "CouponPresent",
"7-0": "ActionResult",
"0-1": "Indicates that the discount is already applied to the order",
"1-1": "When discount is already applied, this value is true\n\nWhen the action, all the conditions and the coupon criteria (no coupon required or coupon present) are met, this value is true.\n\nAll other cases result in the false value.",
"2-1": "If either the action or one of the conditions requires a customer to be present, this value will be true.",
"3-1": "If either the action or one of the conditions requires a customer custom data to be present, this value will be true.",
"4-1": "If either the action or one of the conditions requires a a minimum amount to be present, this value will be true.",
"5-1": "Indicates if the discount requires a coupon.",
"6-1": "Indicates if a coupon matching the discount is present.",
"7-1": "The prefigure result of the action."
},
"cols": 2,
"rows": 10
}

ConditionsResults

The prefigure results of the conditions

Response DataResult object

{
"TypeName": "",
"RequirementsMet": false,
"RequiresCustomer": false,
"RequiresCustomerCustomData": false,
"RequiresMinimumAmount": false,
"RequiresCoupon": false,
"CustomerFilterResult": { *See `CustomFieldFilterResult` object below},
"ProductSetResults": [ { *See `ProductSetResult` object below } ],
"OrderAmountMissing": 0.0,
"OrderAmountMissingForNextTier": 0.0,
}

TypeName: The typename of the action or condition

RequirementsMet: Indicates if all requirements are met.

RequiresCustomer: Indicates if the action or condition requires a customer to be present.

RequiresCustomerCustomData: Indicates if the action or condition requires custom customer data to be present.

RequiresMinimumAmount: Indicates if the action or condition requires a minimum amount to be reached.

CustomerFilterResult: This is the result if the action or condition is CustomField based (for example ‘V2:USERCUSTOMFIELD' condition or 'V2:CUSTOMFIELDVALUEDETERMINEDDISCOUNT’ action. This object returns on which parts of the filter the user meets or doesn’t meet the filter.

ProductSetResults: This is the result if the action or condition is product set based (for example the ‘V2:PRODUCTCONDITION' condition or 'V2:PRODUCTSETDISCOUNTAMOUNT’ )

OrderAmountMissing: Indicates the missing amount to apply the discount

OrderAmountMissingForNextTier: Indicates the missing amount to apply to reach the next tier. This value is only set by actions that have tier based discounts on order amount (for example ‘V2:ORDERTIEREDDISCOUNTPERCENTAGE' or ‘V2:TIEREDPICKAPRODUCT’). When the first tier isn’t reached, the OrderAmountMissing and OrderAmountMissingForNextTier can result into the same amount.

CustomFieldFilterResult object

{
"Matches": false,
"FilterType": 0, -- CustomFieldFilterType enum
"FilterResults": [ *CustomFieldFilterResult ],
"ConditionResults": {
"CustomFieldId": 1,
"ExpectedValue": (CustomFieldValue object),
"CurrentValue": null, -- CustomFieldValue object if present
"CurrentValuePresent": false,
"Matches": false,
}
}

ProductSetResult

{
"ProductSet": (ProductSet object),
"SetQuantityMissing": 0,
"SetQuantityMissingForNextTier": 0,
"ProductQuantityMissing": [
{
"ProductID": 1,
"Quantity": 1,
}
],
"ProductQuantityMissingForNextTier": [
{
"ProductID": 1,
"Quantity": 1,
}
],
"ProductAmountMissing": [
{
"ProductID": 1,
"Amount": 1,
}
],
"ProductAmountMissingForNextTier": [
{
"ProductID": 1,
"Amount": 1,
}
]
}

ProductSet: The ProductSet as given in the discount data to comply to.

SetQuantityMissing: Indicates the missing quantity of a product required by the set before the discount is applicable. This value is only set for discount actions or conditions that have product sets and the setting IdenticalProductsOnly disabled.

For example; V2:PRODUCT condition & V2:PRODUCTSETDISCOUNTPERCENTAGE action

SetQuantityMissingForNextTier: Indicates the missing quantity of products required by the set before the discounts next tier is applicable. This value is only set for discount actions or conditions that have product sets and the setting IdenticalProductsOnly disabled.

For example; V2:PRODUCTQUANTITYTIEREDDISCOUNTPERCENTAGE action

ProductQuantityMissing: Indicates the missing quantity of a specific product before the discount is applicable. This value is only set for discount actions or conditions that have product sets and the setting IdenticalProductsOnly enabled.

For example; V2:PRODUCT condition & V2:PRODUCTSETDISCOUNTPERCENTAGE action

ProductQuantityMissingForNextTier: Indicates the missing quantity of a specific product before the discounts next tier is applicable. This value is only set for discount actions or conditions that have product sets and the setting IdenticalProductsOnly enabled.

For example; V2:PRODUCTQUANTITYTIEREDDISCOUNTPERCENTAGE action

ProductAmountMissing: Indicates the missing amount of a specific product before the discount is applicable. This value is only set for discount actions or conditions that have product sets and the setting IdenticalProductsOnly enabled.

For example; V2:PRODUCTAMOUNTTIEREDDISCOUNTPERCENTAGE action

ProductAmountMissingForNextTier: Indicates the missing amount of a specific product before the discounts next tier is applicable. This value is only set for discount actions or conditions that have product sets and the setting IdenticalProductsOnly enabled.

For example; V2:PRODUCTAMOUNTTIEREDDISCOUNTPERCENTAGE action