Build a business rule
The rule builder is a full-screen editor where you create and edit the logic for a business rule. Each rule consists of one or more subrules displayed as expandable panels that you can reorder by dragging.
This page covers the builder itself. For what each rule type can do, see Business Rules.
Before you begin
- You need the Configuration role to view and edit business rules.
- You need Owner access on the Configuration role to create or delete rules.
The rule builder is a full-screen editor where you create and edit the logic for a business rule. Each rule consists of one or more subrules displayed as expandable panels that you can reorder by dragging.
Set the hit policy
In the header, use the Hit policy toggle to choose how multiple subrules are evaluated:
- First: only the first matching subrule is applied
- All: all matching subrules are applied
Use First when only one outcome should apply, for example tiered discounts where a customer gets the 15% tier or the 10% tier but never both.
Use All when several different outcomes should apply together, for example making three payment methods selectable at once.
A discount always applies to every matching item on its own. You do not need All to discount more than one line, because a single subrule already discounts every qualifying product in the order.
Keep alternatives inside one rule. If two incentive rules both match the same order, only one of them is applied. They do not combine. Build tiers and alternatives as subrules of a single rule, where the hit policy gives you control over which one wins.
Start from the empty subrule
A new incentive rule already contains one empty subrule. Put your conditions in that subrule rather than adding a second one below it.
An empty subrule has no conditions, so it matches every order. With hit policy First the rule stops at the first subrule that matches, so anything below an empty subrule is never reached.
Put an empty subrule at the bottom of the list on purpose. It then acts as a fallback that catches every order the subrules above it did not.
Add conditions (IF)
Conditions define when a subrule should trigger.
- Click Add condition within a subrule.
- Select an Item from the available order fields (for example, Order subtotal, Order postage carrier or Order actioncode).
- Select a Condition operator. The available operators depend on the field type:
- Text fields: Equals, Not equals, Contains, Starts with
- Number fields: Equals, GreaterThan, LessThan, GreaterThanOrEqualTo, Between
- Array fields: Contains, Does not contain
- Enter the Value. Some fields give you a list to pick from, for example the delivery address country. For fields where you type the value yourself, enter the stored code and not the translated label.
You can add multiple conditions per subrule. Combine them with and or or logic using the toggle buttons.
What you can base a rule on
The Item list covers the whole order:
- Order: subtotal, action code and the current date.
- Delivery and invoice address: country, city, region and postal code.
- Shipping and payment: shipping method, carrier and payment method.
- Products in the order: the order's line items.
- The person on the order, whether a contact (part of a company, B2B) or a customer (B2C): type, name, date of birth and their attributes.
- The company (for B2B contacts): name, company ID, debtor ID, created date and its attributes.
The date fields (current date, date of birth and company created date) let you build time-based rules, for example higher shipping costs on a public holiday or a discount for companies created before a certain date.
To base a condition on a company, customer or product attribute, pick the attribute item, then choose which value type to match: Attribute text value, Attribute enum value, Attribute integer value or Attribute decimal value. Match the type the attribute actually uses. If you match a text attribute as an enum value, the condition never matches and the rule silently does not fire.
Text attributes are stored once per language. When you match on Attribute text value, also add a condition on the language, for example NL, next to the value itself. Matching only the value can behave unpredictably when a product has the attribute filled in several languages.
Count the products in an order
When you base a condition on Products in the order, you also choose what to count.
| Count by | What it means | What a value of 2 matches |
|---|---|---|
| Count | How many different products | 2 different products |
| total Quantity | How many pieces | 2 pieces, so either one product ordered twice or two products |
| total Price | The value of the matching products | €2 worth |
Ordering the same product twice does not count as two products. The order shows it as one line with quantity 2, so a rule set to Count 2 does not fire for a customer who buys 2 of the same item.
If your promotion says "order 2 items", you almost always mean total Quantity.
You can also narrow which products count, by product attribute, SKU, category and so on. When you do, only the matching products are counted and only they receive the discount.
Add actions (THEN)
Actions define what happens when the conditions match. The available actions depend on the rule type (see the tables above for each type).
- Click Add action within a subrule.
- Select the action type.
- Fill in the action parameters (for example, select a carrier, enter a price or choose a product).
Add subrules
Click Add subrule in the header to add additional subrules. Each subrule has its own set of conditions and actions. You can rename a subrule by clicking the edit icon next to its name.
Save the rule
Click Save in the header to save all changes. Use the edit icon next to the rule name to rename it (localized with language switcher).
Build a tiered discount
Take a promotion like "order 2 items of a certain type and get 5% off, 3 items 10%, 4 items 15%".
Build this as one rule with three subrules. Set the hit policy to First and put the biggest discount at the top.
| Order | IF products in the order | THEN |
|---|---|---|
| 1 | total Quantity 4 or more of type Premium | Give discount to order item, 15% |
| 2 | total Quantity 3 or more of type Premium | Give discount to order item, 10% |
| 3 | total Quantity 2 or more of type Premium | Give discount to order item, 5% |
Put the highest tier first. With hit policy First the rule stops at the first subrule that matches. If you list the tiers as 2, then 3, then 4, a customer ordering 4 items matches the "2 or more" subrule first and only gets 5%.
Use GreaterThanOrEqualTo for "2 or more" instead of Equals. With Equals 2, a customer who orders 3 gets nothing.
Only the products matching your condition are counted and discounted. Take a basket with three products where two are Premium.
| Product | Type | Price | Customer pays |
|---|---|---|---|
| A | Premium | €68.00 | €64.60 with 5% off |
| B | Premium | €112.00 | €106.40 with 5% off |
| C | Other | €54.00 | €54.00, no discount |
The 5% tier applied because the two Premium products add up to a quantity of 2. Product C does not count toward the tier and does not receive the discount.
Build a "2 + 1 free"
It is tempting to configure this as "33% off when the customer orders 3 or more". That works only when the quantity is an exact multiple of 3.
| Ordered | Free items with 33% off | Should be |
|---|---|---|
| 3 | 1 | 1 |
| 4 | 1.33 | 1 |
| 5 | 1.67 | 1 |
| 6 | 2 | 2 |
At 4 and 5 the customer gets more than the deal promises. A percentage always discounts the whole line, so it cannot round down to complete sets.
Use Add product to bonus items instead.
| Field | Value |
|---|---|
| Condition | Products in the order, total Quantity, GreaterThanOrEqualTo 2 |
| Action | Add product to bonus items |
| Price | 0 |
| Quantity | 1 |
| Repeat | On |
This adds one free item for every two bought and rounds down correctly at every quantity: 2 gives 1 free, 4 gives 2, 5 gives 2 and 12 gives 6.
Set the Price to 0. If you leave it empty the bonus item is added at a reduced price instead of free.
The action asks for a specific Product ID, so it always gives back that product even when the customer bought a different qualifying one. For a promotion across several products you need one rule per product, and only one incentive rule applies per order.
Check that your rule works
- In the webshop, add the qualifying products to a cart. Shipping costs, carriers, payment methods, transaction costs and incentives all recalculate automatically whenever the cart changes.
- In the Sales Hub, the other rule types recalculate automatically but incentives do not. Click Apply incentives on the quote or order to trigger them.
- Check the result on the order lines. A discounted line shows the reduced price and the name of the incentive that was applied.
You can apply incentives only once per quote or order. Test your rule on a throwaway quote before you use it on a real one. See Create Quote and Create Order.
If nothing happens, check these causes first:
- You counted different products instead of pieces. See Count the products in an order.
- You used Equals where you meant "2 or more".
- You ordered the subrules smallest tier first with hit policy First.
- You matched an attribute as the wrong value type, or matched a text attribute without its language.
- The attribute you picked is not the one you meant.
LOADdoes not match an attribute calledLOAD_INDEX, and you get no warning. The condition simply matches nothing. - No product actually carries the value you are matching on. Check a product in the PIM before you assume the rule is wrong.