Condition: AdvancedCriteria__c Field Specification
The orders__AdvancedCriteria__c field is used to specify the complex logic specified in JSON format for granting discounts in an order.
The logic is applied when the Calculation Method on the Condition object is Advanced.
Advanced Criteria 1.0
The Advanced Criteria field is used to define the group discount for the product. It means that the condition in Condition Details and additionally the condition specified in this field must be satisfied.
For example, specify products that affect the discount or the presence of which product can determine whether a discount will be granted. Also, there are the products, whose quantity would determine whether a suitable Condition Level record would be selected. The quantity is counted for all products, that matched the condition in the Advanced Criteria field. This syntax is also applied for parsing the Criteria Based and List Based freebies. All Order Line Items of the order will. be checked.
Click to see the example
{
"levelConditions": {
"operator": "AND",
"productCount": {
"filter": {
"operator": "AND",
"items": [
{
"field": "orders__PromotionId__c", // If the promotion has an External Id, use orders__PromotionId__r.orders__ExternalId__c
"operator": "equal",
"value": "a0C6g000000RHusEAG" // Salesforce ID or External ID
},
{
"field": "orders__PromotionLineItemId__r.orders__IsRequired__c",
"operator": "equal",
"value": "true"
},
{
"field": "orders__PromotionLineItemId__r.RecordType.DeveloperName",
"operator": "equal",
"value": "PromotionProduct"
}
]
},
"minCount": 3
},
"requiredProducts": {
"productIdField": "orders__ProductId__r.CTCPG__ExternalId__c", // If the products with a specified minimum quantity have an External Id, use it; otherwise, use the Salesforce ID in orders__ProductId__c
"operator": "AND",
"items": [
{
"product": "prod001", // Salesforce ID or External ID
"minQuantity": 5 // Minimum quantity
},
{
"product": "prod002",
"minQuantity": 5
}
]
}
},
"levelBasedOnFilter": { // Define where to calculate product quantity
"operator": "AND",
"items": [
{
"field": "orders__PromotionId__c", // When a Promotion has External Id, specify orders__PromotionId__r.orders__ExternalId__c
"operator": "equal",
"value": "a0C6g000000RHusEAG" // Salesforce ID or External ID
},
{
"field": "orders__PromotionLineItemId__r.orders__IsRequired__c",
"operator": "equal",
"value": "true"
},
{
"field": "orders__PromotionLineItemId__r.RecordType.DeveloperName",
"operator": "equal",
"value": "PromotionProduct"
}
]
}
}
Advanced Criteria 2.0
Advanced Criteria 2.0 provides more flexibility when granting discounts by setting multiple filters at the same time, as well as a minimum number of products for different size discounts. The logic is also affected by the value specified in the Apply Condition Type field.
See the example below, where the discount will be applied when one of the conditions is met.
-
4 SKUs from Brand1 and 2 SKUs from Brand2
-
6 SKUs from Brand3 and 4 SKUs from Brand4
-
4 SKUs from Brand4 and 2 SKUs from Brand5
Click to view an example
{
"version":2,
"condition":{
"operator":"OR",
"items":[
{
"operator":"AND",
"items":[
{
"filter":{
"operator":"AND",
"items":[
{
"field":"orders__ProductId__r.orders__Brand__c",
"operator":"equal",
"value":"Brand1"
}
]
},
"minCount":4
},
{
"filter":{
"operator":"AND",
"items":[
{
"field":"orders__ProductId__r.orders__Brand__c",
"operator":"equal",
"value":"Brand2"
}
]
},
"minCount":2
}
]
},
{
"operator":"AND",
"items":[
{
"filter":{
"operator":"AND",
"items":[
{
"field":"orders__ProductId__r.orders__Brand__c",
"operator":"equal",
"value":"Brand3"
}
]
},
"minCount":6
},
{
"filter":{
"operator":"AND",
"items":[
{
"field":"orders__ProductId__r.orders__Brand__c",
"operator":"equal",
"value":"Brand4"
}
]
},
"minCount":4
}
]
},
{
"operator":"AND",
"items":[
{
"filter":{
"operator":"AND",
"items":[
{
"field":"orders__ProductId__r.orders__Brand__c",
"operator":"equal",
"value":"Brand5"
}
]
},
"minCount":4
},
{
"filter":{
"operator":"AND",
"items":[
{
"field":"orders__ProductId__r.orders__Brand__c",
"operator":"equal",
"value":"Brand6"
}
]
},
"minCount":2
}
]
}
]
},
"levelBasedOnFilter":{
"operator":"AND",
"items":[
{
"field":"orders__PromotionId__r.orders__ExternalId__c",
"operator":"equal",
"value":"all_bb_kefir"
},
{
"field":"orders__PromotionLineItemId__r.orders__IsUseForDiscount__c",
"operator":"equal",
"value":"true"
},
{
"field":"orders__PromotionLineItemId__r.RecordType.DeveloperName",
"operator":"equal",
"value":"Product"
}
]
}
}
JSON Key Description
Advanced Criteria
It is used to define the Advanced Criteria version and set up conditions.
| Key | Type | Required | Comment |
|---|---|---|---|
version |
Number |
No |
The version of the advanced criteria to apply. Available values:
|
condition |
Object |
No |
Conditions on the number of unique products and mandatory products to get a discount. To use several conditions, apply AND and OR operators. Required for Advanced Criteria 2.0. |
levelConditions |
Object |
No |
Conditions on the number of unique products and mandatory products to get a discount. Required for Advanced Criteria 1.0. |
Condition
The applied condition.
| Key | Type | Required | Comment |
|---|---|---|---|
operator |
Enum |
Yes |
Available values:
|
items |
Array |
Yes |
The required condition. Available values:
The condition must contain minCount or requiredProducts. If filter is used, the minCount or requiredProducts logic will be applied to the products that match the filter criteria. |
Filter
A filter defines which Order Line Items can be used for calculating a unique number of products or required products.
| Key | Type | Required | Comment |
|---|---|---|---|
operator |
Enum |
Yes |
Available values:
|
items |
An array of Filter Items |
Yes |
See Filter Items. At least one item must be provided. |
Filter Items
| Key | Type | Required | Comment |
|---|---|---|---|
field |
String |
Yes |
The field from the Order Line Item or its parent object for which the operator key is applied. |
operator |
Enum |
Yes |
See Item Operators. |
value |
Boolean |
No |
A target value for fields with the Boolean type. |
Number |
A target value for fields with the Currency or Number type. |
||
String |
A target value for fields with the Text type. The key is required when the operator key is not in or notIn. |
||
values |
Array of Values |
No |
The values with the Text type, separated by a comma, for example: ["abc","123"] At least one item must be provided. The key is required when the operator key is in or notIn. |
Minimum Quantity
The minimum quantity of unique products that must be added to order to get a discount.
| Key | Type | Required | Comment |
|---|---|---|---|
minCount |
Number |
Yes |
The number of products. The discount will not be calculated if the actual number of products is less than that specified for that key. |
Required Products
The required products to get a discount.
| Key | Type | Required | Comment |
|---|---|---|---|
productField |
String |
Yes |
The identification to search required products.
|
operator |
Enum |
Yes |
The operator defines how to apply the logic:
|
items |
An array of Required Product Items |
Yes |
The list of required products. See the Required Product Items. The condition may be satisfied if there are no specified values. |
Required Product Items
The list of required products to get a discount.
| Key | Type | Required | Comment |
|---|---|---|---|
product |
String |
Yes |
Available values:
|
minQuantity |
Number |
Yes |
The product minimum quantity |
Level Based on Filter
The list of products that affect the group discount. These products' quantity is compared with the value in the StartingFrom__c field on the Condition Level record.
Applied after levelConditions and requiredProducts are calculated. If those conditions were not met, the Level Based on Filter will not be calculated.
| Key | Type | Required | Comment |
|---|---|---|---|
operator |
Enum |
Yes |
Available values:
|
items |
An array of Level Based on Filter Items |
Yes |
At least one item must be provided. |
Level Based on Filter Items
Specify operator and items values that are used to check if values on Order Line Items are a match.
The format is the same as for the orders__ConditionDetails__c field.
| Key | Type | Required | Comment |
|---|---|---|---|
field |
String |
Yes |
The field from the Order Line Item or its parent object for which the operator key is applied. |
operator |
Enum |
Yes |
See Item Operators. |
value |
Boolean |
No |
A target value for fields with the Boolean type. |
Number |
A target value for fields with the Currency or Number type. |
||
String |
A target value for fields with the Text type. The key is required when the operator key is not in or notIn. |
||
values |
Array of Values |
No |
The values with the Text type, separated by a comma, for example: ["abc","123"] At least one item must be provided. The key is required when the operator key is in or notIn. |