Understanding the Rule Builder

Understanding the Rule builder

The Rule builder is at the heart of the function builder and allows you to build exhaustive logic for your discount function.

With the Rule builder You can create rules that determine when discounts are applied to items in a customer's shopping cart. Each line in the cart is checked against these rules. If all conditions are met, the discount is applied.

How it Works:

  • You set up conditions in the Rule Builder.

  • Each line item in the cart is checked against these conditions.

  • If an item satisfies all the conditions, it gets the discount.

Note: If there are multiple discounts or limit on the lines , the order and way they are applied depend on the Discount Application Strategy and Line limit strategy you have configured.

Let's understand this with an example ?

Example: Let's say you have a discount that applies if all the below conditions are met:

  • Condition 1: The cart subtotal must be greater than $100 (Cart sub total > $100).

  • Condition 2: The customer must be logged in (Customer logged in = true).

  • Condition 3: The product must be from a specific vendor, say "Vendor A" (Product Vendors = Vendor A).

Let's test our logic on a user's cart

Here's an example cart from a user that we'll test our logic on, assuming that the customer is logged in.

  • Item 1: Price = $50, Vendor = Vendor A

  • Item 2: Price = $60, Vendor = Vendor B

  • Item 3: Price = $30, Vendor = Vendor A

Finding 1 → The cart subtotal is $140 (which is greater than $100), and the customer is authenticated.

Finding 2 → The discount is applied to Item 1 and Item 3, but not to Item 2. This way, the rule ensures that only the eligible items get the discount based on the conditions set.


Walkthrough of the Rule builder UI

  1. The + OR button (1 - in the screenshot) allows you to combine multiple conditions, and the discount is applied on the product if ANY of the conditions within the condition are satisfied. (reference)

  2. The + AND button (2 - in the screenshot) allows you to combine multiple conditions, and the discount is applied only if ALL the conditions satisfied (reference)

  3. The Add discount button (3 - in the screenshot) enables you to create multiple discounts, each with its own set of rules that are defined using simple AND, OR logics. (reference)

By default, when creating a function, you start with a discount with a single placeholder condition setup.

Last updated