The power of the rule engine
How to set up rules & use cases
- Checkout
- Business
Alvaro Millan
Business Analyst
The Rule Engine can be used to restrict the checkout options configured for your shop. Checkout options are based on certain conditions (rules) that you set in the SCAYLE Panel. This page describes aspects of the Rule Engine including:
Checkout options correspond to different results in the Rule Engine. Based on whether conditions are met (e.g., order > cost > withTax
<= 500 ), options can be:
All options have to be configured before you can restrict them in the Rule Engine (please contact your SCAYLE Account Manager for questions about this configuration). You can't influence the order of options.
Option categories include:
Results under Delivery Options include:
Methods may vary based on your specific checkout configuration. Some example payment options include:
The available shipping options are based on specific tenant architecture. Some required shipping options for the Rule Engine have to be added. Shipping options available by default include:
It is possible to configure the kind of collection points that are available on the map. Only collection point deactivation is possible.
Rules (conditions) are created at the shop level.
You can add subconditions to a rule to handle complex scenarios. However within one rule, use the same operator - do not mix AND/OR operators within the same rule. For more details, see Use Cases.
Since the rules disable options, it is easier to start with the more general excludes and then become more specific. For example, first exclude shipping options that are not relevant for one country so you don't have to repeat the exclusion in every rule.
Shops > Storefront > Checkout Settings > Rule Engine
.order
, customer
, payment
).order
> id
, customer
> lastName
, payment
> amount
).=
, !=
, >
, <
, <=
, IS
, IS NOT
, IN
, NOT IN
) and corresponding value (e.g., 10
, London
).+ SUB CONDITION
button. AND
/OR
operators.Payment Options
> All Payment Methods
> Deactivate Payment Method
).When adding a subcondition, you have to choose the same operator for multiple subconditions within the rule. For more details, see Use Cases.
Shops > Storefront > Checkout Settings > Rule Engine
.Edit
.Shops > Storefront > Checkout Settings > Rule Engine
.Deactivate
.Shops > Storefront > Checkout Settings > Rule Engine
.Delete
.The following examples are intended to explain some real-world scenarios.
Complex scenarios might include conditions and subconditons. Within one condition you can only set subconditons using the same operator (AND/OR).
A rule can be set for payment methods requiring a minimum order value (MOV). For example, you may want to disable the Accounting (B2B) payment method for orders less than a threshold. If MOV is not reached, the payment method is deactivated (does not appear in Checkout).
order
> cost
> withoutServiceCost
<=
5000
(50.00).Payment Options
> Accounting
| Deactivate Payment Method.
Below is a sample rule set for an order with a max order value of 700 €. All payment methods will be deactivated if the customer orders items that cost higher than 700 €.
order
> cost
> withTax
>
70000
(700.00)Payment Options
> All Payment Methods
| Disable Payment Method
Payment Options
> All Payment Methods
| Trigger Error Message
A rule can be set to enable/disable specific shipping costs for a given shipping country (global or EU shop). For example, you can create a rule where, if a customer selects a shipping country, all shipping options are disabled that do not have a specific cost.
For details on setting Shipping Options (including shipping cost) see Shipping Options.
address
> shipping
> countryCode
IS
TUR
Shipping Options
> rule-engine.available_shipping_options.1299
| Deactivate Shipping Options
Shipping Options
> rule-engine.available_shipping_options.1546
| Deactivate Shipping Options
Shipping Options
> rule-engine.available_shipping_options.1427
| Deactivate Shipping Options
For conditions with countryCode
use the "iso_alpha3” (e.g., for Germany it is DEU).
Rules can be set to enable free shipping for a given time period (e.g., promotion campaign). This requires 2 rules, one to enable free shipping and another to define standard shipping outside the free shipping time period.
order
> cost
> withoutServiceCost
>=
4000
(40.00)client
> currentTime
between
06-03-2023 09:00:00 - 09-03-2023 00:00:00
Shipping Options
> DHL Standard
| Deactivate Shipping Options
client
> currentTime
before
06-03-2023 09:00:00
client
> currentTime
after
09-03-2023 00:00:00
order
> cost
> withoutServiceCost
<=
4000
(40.00)Shipping Options
> DHL Standard (free shipping)
| Deactivate Shipping Options
You can set a rule containing multiple statements, however within a statement, use the same operator. A single rule can contain multiple subconditions joined by one operator (such as a sub-condition AND another subcondition AND another subcondition), but you cannot mix operators within a single rule. To add a statement with a different operator, create a new rule.
One rule targets:
To target women who live in Berlin OR in Hamburg, we have to add a new condition, as we cannot mix operators AND/OR within the same condition statement.
Shops > Storefront > Checkout Settings > Rule Engine
customer > gender > ADD
.IS
and select f
from the dropdown. Specify the timeframe:+SUB CONDITION
, then order > createdAt > datetimeOperations > ADD
. Select before
from the dropdown. Pick the date and time from the calendar.order > updatedAt > datetimeOperations > ADD
. Select after
from the dropdown. Pick the date and time from the calendar.Add new condition to specify location
OR
operator:address > shipping > city > ADD
. Type a city, for example "Berlin".+SUB CONDITION
, then address > shipping > city > ADD
. Type a city, for example "Hamburg".OR
.Shipping Options
> DHL Standard
| Deactivate Shipping Options.
You can access a variety of properties to build your custom rules. Rules can be written on the following standardized data structure. Not all information will be available from beginning to end during the ordering process, for example a shipping address will not yet be available for new customers when evaluating rules for the delivery options filter.
{
"address": {
"billing": {
"id": 998,
"additional": "c/o SCAYLE",
"city": "Hamburg",
"countryCode": "DEU",
"houseNumber": "12",
"isDefault": {
"billing": false,
"shipping": false
},
"recipient": {
"firstName": "Anna",
"gender": "m",
"lastName": "Doe"
},
"referenceKey": "address-7656",
"street": "Hauptstraße",
"zipCode": "20459"
},
"shipping": {
"id": 998,
"city": "Hamburg",
"collectionPoint": {
"customerKey": "bced-234-234",
"description": "Pedro's Kiosk",
"key": "12345-a",
"type": "hermes_parcelshop"
},
"countryCode": "DEU",
"houseNumber": "10",
"isDefault": {
"billing": false,
"shipping": false
},
"recipient": {
"firstName": "Anna",
"gender": "m",
"lastName": "Doe"
},
"referenceKey": "address-7656",
"street": "Domstrasse",
"zipCode": "20459"
}
},
"application": {
"appId": 139,
"countryCode": "DEU",
"currencyCode": "EUR",
"device": "desktop",
"languageCode": "DE"
},
"client": {
"currentTime": "2018-01-20T09:30:15+00:00",
"ip": "0.0.0.0",
"languageCode": "FR",
"location": {
"city": "Offenbach",
"countryCode": "DEU",
"region": "Hessen"
},
"userAgent": {
"browser": "Chrome",
"device": "desktop",
"platform": "Windows",
"version": "7.0"
}
},
"customer": {
"id": 9876,
"authentication": {
"data": {
"accessToken": "a0we0effg424",
"userId": "567765"
},
"type": "password"
},
"birthDate": "1981-02-02",
"customData": {
"score": {
"requestFailed": true
}
},
"email": "[email protected]",
"firstName": "Anna",
"gender": "f",
"groups": [
{
"item": "new"
},
{
"item": "app"
}
],
"lastName": "Doe",
"phone": "0049/1234567890",
"referenceKey": "customer-1234",
"status": {
"isActive": true,
"isGuestCustomer": false,
"isTestCustomer": false
},
"createdAt": "2018-01-20T09:30:15+00:00",
"updatedAt": "2018-01-20T09:30:15+00:00"
},
"items": [
{
"availableQuantity": 20,
"customData": {
"key": "value"
},
"deliveryForecast": {
"deliverable": {
"key": "directShipping",
"quantity": 18
},
"subsequentDelivery": {
"key": "christmas",
"quantity": 2
}
},
"itemGroup": {
"id": "ab123",
"isMainItem": true,
"isRequired": true
},
"key": "ac834d23e689u678",
"packageId": 1,
"price": {
"appliedReductions": [
{
"amount": {
"absoluteWithTax": 100,
"relative": 0.5
},
"category": "sale",
"type": "relative"
}
],
"reference": {
"size": "100",
"unit": "ml",
"withTax": 595
},
"tax": {
"vat": {
"amount": 190,
"rate": 0.19
}
},
"withoutTax": 1000,
"withTax": 1190
},
"product": {
"id": 4564545,
"advancedAttributes": {
"materialCompositionTextile": {
"key": "materialCompositionTextile",
"label": "Materialzusammensetzung",
"values": [
{
"fieldSet": [
[
{
"value": "Lining"
}
]
],
"groupSet": [
{
"fieldSet": [
[
{
"value": 80
},
{
"unit": "%"
},
{
"material": "Cotton"
}
]
],
"groupSet": [
]
}
]
}
]
}
},
"attributes": {
"description": {
"key": "description",
"label": "Beschreibung",
"values": [
{
"id": 1234,
"label": "A descriptive string (possibly including HTML)",
"value": "Optional value"
}
]
}
},
"categories": [
[
{
"categoryId": 20201,
"categoryName": "Frauen",
"categoryProperties": {
"priority": {
"name": "priority",
"value": "1"
}
},
"categoryUrl": "/frauen"
}
]
],
"definingAttributes": [
{
"key": "color",
"label": "Farbe"
}
],
"images": [
{
"attributes": {
"description": {
"key": "description",
"label": "Beschreibung",
"values": [
{
"label": "A descriptive string (possibly including HTML)"
}
]
}
},
"hash": "9f6c628a98106dcce2bc5a4ac1de9c14"
}
],
"masterKey": "480306626-1",
"name": "Chelsea Boots",
"createdAt": "2018-01-20T09:30:15+00:00",
"updatedAt": "2018-01-20T09:30:15+00:00"
},
"status": "available",
"variant": {
"id": 1234567,
"attributes": {
"vendorSize": {
"key": "vendorSize",
"label": "Größe",
"values": [
{
"id": 25472,
"label": "34",
"value": "Thirty Four"
}
]
}
},
"referenceKey": "563843898",
"stock": {
"customData": {
},
"deliveryForecast": {
"deliverable": {
"key": "directShipping",
"quantity": 18
},
"subsequentDelivery": {
"key": "christmas",
"quantity": 2
}
},
"isSellableWithoutStock": false,
"quantity": 18,
"supplierId": 271
},
"createdAt": "2018-01-20T09:30:15+00:00",
"updatedAt": "2018-01-20T09:30:15+00:00"
},
"createdAt": "2018-01-20T09:30:15+00:00",
"updatedAt": "2018-01-20T09:30:15+00:00"
}
],
"order": {
"id": 123,
"appliedLoyaltyPoints": 0,
"basketKey": "basket-c6v7k4eer1",
"cost": {
"appliedReductions": [
{
"amount": {
"absoluteWithTax": 100,
"relative": 0.5
},
"category": "voucher",
"type": "absolute"
}
],
"capture": 1090,
"tax": {
"vat": {
"amount": 123,
"rate": 0.5
}
},
"withoutServiceCost": 1190,
"withoutTax": 1000,
"withTax": 1190
},
"currencyCode": "EUR",
"customData": {
"score": {
"requestFailed": true
}
},
"referenceKey": "order-2234",
"createdAt": "2018-01-20T09:30:15+00:00",
"updatedAt": "2018-01-20T09:30:15+00:00"
},
"packages": [
{
"id": 1,
"carrierKey": "dhl",
"deliveryDate": {
"maximum": "2018-02-05",
"minimum": "2018-02-02"
},
"deliveryStatus": "open",
"returnIdentCode": "100-1",
"shipmentKey": "shpmnt-100-1",
"tracking": {
"id": "79003131200523",
"url": "https://tracking.hermesworld.com/?TrackID=79003131200523"
}
}
],
"payment": [
{
"amount": 1190,
"data": {
"CCBrand": "VISA",
"CCExpiry": "202005",
"IPCity": "charlottenburg",
"IPLatitude": "52.5151",
"IPLongitude": "13.3053",
"IPState": "berlin",
"IPZone": "276",
"IPZoneA2": "de"
},
"key": "computop_creditcard",
"transactionKey": "creditcard-abcde"
}
],
"vouchers": [
{
"id": 198234,
"applicableItems": [
{
"isApplied": true,
"key": "a87ff679a2f3e71d9181a67b7542122c"
},
{
"isApplied": false,
"key": "eccbc87e4b5ce2fe28308fd9f2a7baf3"
}
],
"code": "fashion2020",
"type": "absolute",
"value": 1000
}
]
}
{
"address": {
"billing": {
"id": "integer",
"additional": "string",
"city": "string",
"collectionPoint": {
"customerKey": "string",
"description": "string",
"key": "string",
"type": "string"
},
"countryCode": "string",
"houseNumber": "string",
"isDefault": {
"billing": "boolean",
"shipping": "boolean"
},
"recipient": {
"firstName": "string",
"gender": "enum",
"lastName": "string"
},
"referenceKey": "string",
"street": "string",
"title": "string",
"zipCode": "string"
},
"shipping": {
"id": "integer",
"additional": "string",
"city": "string",
"collectionPoint": {
"customerKey": "string",
"description": "string",
"key": "string",
"type": "string"
},
"countryCode": "string",
"houseNumber": "string",
"isDefault": {
"billing": "boolean",
"shipping": "boolean"
},
"recipient": {
"firstName": "string",
"gender": "enum",
"lastName": "string"
},
"referenceKey": "string",
"street": "string",
"title": "string",
"zipCode": "string"
}
},
"application": {
"appId": "integer",
"countryCode": "string",
"currencyCode": "string",
"device": "string",
"languageCode": "string"
},
"client": {
"currentTime": "string",
"ip": "string",
"languageCode": "string",
"location": {
"city": "string",
"countryCode": "string",
"region": "string"
},
"userAgent": {
"browser": "string",
"device": "string",
"platform": "string",
"version": "string"
}
},
"customer": {
"id": "integer",
"authentication": {
"data": {
"accessToken": "string",
"userId": "string"
},
"type": "enum"
},
"birthDate": "string",
"customData": {},
"email": "string",
"firstName": "string",
"gender": "enum",
"groups": [
{
"item": "string"
}
],
"lastName": "string",
"phone": "string",
"publicKey": "string",
"referenceKey": "string",
"status": {
"isActive": "boolean",
"isGuestCustomer": "boolean",
"isTestCustomer": "boolean"
},
"title": "string",
"type": "enum",
"createdAt": "string",
"updatedAt": "string"
},
"items": [
{
"availableQuantity": "integer",
"customData": {},
"deliveryForecast": {
"deliverable": {
"key": "string",
"quantity": "integer"
},
"subsequentDelivery": {
"key": "enum",
"quantity": "integer"
}
},
"itemGroup": {},
"key": "string",
"packageId": "integer",
"price": {
"appliedReductions": [
{
"amount": {},
"absoluteWithTax": "integer",
"relative": "number",
"category": "enum",
"type": "enum"
}
],
"reference": {
"size": "string",
"unit": "string",
"withTax": "integer"
},
"tax": {
"$key": {}
},
"withoutTax": "integer",
"withTax": "integer"
},
"product": {
"id": "integer",
"advancedAttributes": {},
"attributes": {},
"categories": [
{
"categoryHidden": "boolean",
"categoryId": "integer",
"categoryName": {},
"categoryProperties": {},
"categoryUrl": {}
}
],
"definingAttributes": [
{
"key": "string",
"label": "string"
}
],
"images": [
{
"attributes": {},
"hash": "string"
}
],
"masterKey": "string",
"name": "string",
"createdAt": "string",
"updatedAt": "string"
},
"reservationKey": "string",
"status": "enum",
"variant": {
"id": "integer",
"advancedAttributes": {},
"attributes": {},
"referenceKey": "string",
"stock": {
"customData": {},
"deliveryForecast": {},
"deliverable": {},
"subsequentDelivery": {},
"isSellableWithoutStock": "boolean",
"quantity": "integer",
"supplierId": "integer"
},
"createdAt": "string",
"updatedAt": "string"
},
"warehouseId": "integer",
"createdAt": "string",
"updatedAt": "string"
}
],
"order": {
"id": "integer",
"appliedLoyaltyPoints": "integer",
"basketKey": "string",
"campaignKey": "string",
"confirmedAt": "string",
"cost": {
"appliedFees": [
{
"amount": {},
"category": "enum",
"key": "string",
"option": "string"
}
],
"appliedReductions": [
{
"amount": {},
"absoluteWithTax": "integer",
"relative": "number",
"category": "enum",
"type": "enum"
}
],
"capture": "integer",
"tax": {
"$key": {}
},
"withoutServiceCost": "integer",
"withoutTax": "integer",
"withTax": "integer"
},
"currencyCode": "string",
"customData": {},
"referenceKey": "string",
"createdAt": "string",
"updatedAt": "string"
},
"packages": [
{
"id": "integer",
"carrierKey": "string",
"deliveryDate": {
"maximum": "string",
"minimum": "string"
},
"deliveryStatus": "enum",
"returnIdentCode": "null,string",
"shipmentKey": "string",
"tracking": {
"id": "string",
"url": "string"
}
}
],
"payment": [
{
"amount": "integer",
"data": {},
"installment": [
{
"amount": "integer",
"type": "enum"
}
],
"key": "string",
"paymentMethod": "string",
"status": "enum"
}
]
}
The power of the rule engine
Alvaro Millan
Business Analyst