The new Rules Engine changes the game for how to do promotions.
Today we are announcing the release of our new Rules Engine, a very powerful API that delivers new capabilities to our enterprise customers. The Rules Engine provides the flexibility to create highly customized promotions, discounts, and pricing strategies that will unlock broader growth opportunities previously inaccessible. Customers can use the Engine with our Flex Promotions, allowing conditions and actions to be defined that automatically apply discounts and promotions based on a wide range of order attributes. Whether you need to target specific customer segments, incentivize purchases of certain products, or offer free shipping based on location, the Rules Engine can cover just about any use case.
Our solid promotions foundation
From the beginning, we’ve recognized that ecommerce success can hinge on running effective promotions. A number of industry studies endorse the importance of an effective promotion strategy:
- 91% of consumers say promotions influence their purchasing decisions
- Companies using advanced promotion engines see a 2.5x higher ROI on promotional spend.
- Smart promotional strategies reduce dead stock by up to 35%
Our core API supports promotions around two key concepts: the promotions themselves and promotion rules. Think of the promotion as the actual discount or benefit, like "20% off" or "free shipping", while promotion rules are the conditions that need to be met to get that benefit. It's similar to how a loyalty program might work. The benefit might be a free coffee (i.e. the promotion), but the rule is that you need to buy 10 coffees first.
The initial set of promotions rules we built have been “static”. We’ve offered promotions based on rules like the order amount, specific products or combinations of products, or a set of customizations you can configure. These have served as a “semi-smart assistant” that decides when and how to apply discounts to customers' orders. Just as a helpful store employee might say "Oh, you've bought over $100 worth of items, so you qualify for our 20% discount!" or "I see you have a coupon code, let me apply that for you," our promotions API checks that various conditions are met and applies discounts when appropriate.
How the Rules Engine works
While the initial set of promotions discussed have covered a large set of the most common use cases, they are still limited in what they can do. Every brand should be able to implement unique promotions with clever rules that help them sell more products. That’s why we created the Rules Engine (with Flex Promotions) to be one of the most powerful promotions engines in the market today.
The Engine allows you to define and manage rules ranging from simple to complex logic. It evaluates specific payloads to ensure conditions are met, triggering the corresponding actions. The Rules Engine comes with a core set of key features:
- Flexible rule definition: Supports a wide array of use cases through integration with the Commerce Layer Core API, enabling a versatile promotional system.
- Current integrations: Initially supports promotions and price lists, with plans for expansion to additional resources.
- Comprehensive examples: Provides JSON snippets and examples focused on order rules, adaptable for creating other types of rules.
What makes the Rule Engine different from our existing promotion is that it is a “Domain-Specific Language” (DSL) tailored specifically for commerce applications, allowing precise rule creation and management. And like our first iteration with promotions, the Rules Engine is integrated with our Core API to seamlessly enhance promotional capabilities. The Rules Engine is perfect for businesses seeking advanced promotional tools and flexible rule management to optimize their operations and marketing strategies.
As mentioned above, the Rules Engine will initially power all Flex Promotions, which provide even more flexibility compared to the Custom Rules described above. (Coupons will also work with the new Rules Engine just like they have worked the fixed rules discussed.)
Let’s take a look at some of the powerful things you can do with Flex Promotions and the new Rules Engine.
Real-world Flex Promotion examples
The Rules Engine and Flex Promotions require a basic level of knowledge of constructing structured data with JSON. Let's dive into three practical examples of custom rules to see what the JSON looks like, how they work, and how they can solve specific business needs.
Use case: Discount line items based on price
In competitive retail environments, strategic discounting on premium products can be an effective way to drive sales of high-value items while maintaining profit margins. This example demonstrates how to configure the rules engine to automatically apply a fixed discount to any product priced above a certain threshold.
This approach allows merchants to incentivize purchases of premium products without affecting the pricing of lower-cost items. It's particularly useful for increasing the average order value and moving higher-priced inventory.
The rule
This is how you would structure the JSON to create this promotion:
{
"rules": [
{
"name": "Get $25 off if the price of the item is >= $999",
"conditions": [
{
"field": "order.line_items.unit_amount_cents",
"matcher": "gteq",
"value": 9999,
"group": "discountable-items"
}
],
"actions": [
{
"type": "fixed_amount",
"value": 2500,
"selector": "order.line_items",
"groups": [
"discountable-items"
]
}
]
}
]
}
How it works
- Condition with Grouping: The rule identifies and groups qualifying items
field
: Targets the unit price of each line item in centsmatcher
: "gteq" means "greater than or equal to"value
: 9999 represents $99.99group
: "discountable-items" assigns qualifying items to a named group
- Targeted Action: Apply a fixed discount to items in the defined group
type
: "fixed_amount" indicates a specific dollar amount discountvalue
: 2500 represents a $25.00 discountselector
: "order.line_items" targets line items in the ordergroups
: Limits the action to only affect items in the "discountable-items" group
Result
When a customer adds products priced at $99.99 or more to their cart, each qualifying item automatically receives a $25.00 discount. This discount is applied per item, not just once per order.
Let's say an order contained 4 line items, but only 2 items met the price threshold. One of the qualifying items had a quantity of 2, resulting in a $50.00 discount for that line (2 × $25.00), while the other qualifying item had a quantity of 1, resulting in a $25.00 discount. The total discount applied would be $75.00 across all qualifying items.
The rules engine handles the identification of eligible items and the application of discounts automatically, without requiring manual intervention or coupon codes.
Use Case: Discount products based on customer email domain
This example demonstrates a powerful business scenario where you can reward customers from specific organizations with automatic discounts. For instance, you might want to offer special pricing to employees of partner companies, educational institutions, or even your own staff.
The rule below identifies customers based on their email domain and applies a significant discount to all products in their order. This approach allows for precise targeting without requiring coupon codes or manual intervention.
The rule
This is how you would structure the JSON to create this promotion:
{
"rules": [
{
"name": "Customer email domain mybrand.com / example.com",
"conditions_logic": "or",
"conditions": [
{
"field": "order.customer_email",
"matcher": "matches",
"value": ".*@mybrand.com"
},
{
"field": "order.customer_email",
"matcher": "matches",
"value": ".*@example.com"
}
],
"actions": [
{
"type": "percentage",
"selector": "order.line_items.sku",
"value": 0.15
}
]
}
]
}
How it works
- Multiple Conditions with OR Logic: The rule uses two conditions connected by "or" logic
conditions_logic
: "or" means either condition can trigger the action- First condition: Checks if email ends with "@mybrand.com"
- Second condition: Checks if email ends with "@example.com"
matcher
: "matches" allows for pattern matching using regular expressions
- Targeted Action: When either condition is met, apply a 15% discount to all SKU items
type
: "percentage" for a percentage-based discountselector
: "order.line_items.sku" targets only line items with SKUsvalue
: 0.15 represents a 15% discount
Result
When a customer with an email address from either "@mybrand.com" or "@example.com" places an order, all products with SKUs automatically receive a 15% discount. This allows businesses to offer special pricing to partner organizations or specific customer segments.
Let's say a customer with the email "john.doe@mybrand.com" placed an order containing 5 line items, 4 of which qualified. The Rules Engine would identify the qualifying email domain and apply the 15% discount to all 4 SKU items.
Use case: Automatic discount for credit card payments
In today's competitive ecommerce landscape, encouraging customers to use specific payment methods can provide significant business advantages. This example demonstrates how to configure the Rules Engine to automatically reward customers who choose to pay with credit cards by applying an instant discount to their purchase.
By incentivizing credit card payments, merchants can benefit from faster settlement times, reduced payment processing fees (compared to some alternative payment methods), and potentially higher conversion rates. This rule makes the incentive transparent and automatic, enhancing the customer experience.
The rule
This is how you would structure the JSON to create this promotion:
{
"rules": [
{
"name": "Discount 3% if paid by credit card",
"conditions": [
{
"field": "order.payment_method.payment_source_type",
"matcher": "eq",
"value": "credit_cards"
}
],
"actions": [
{
"type": "percentage",
"selector": "order",
"value": 0.03
}
]
}
]
}
How it works
- Condition: The rule checks if the payment source type is "credit_cards"
field
: Specifies the path to check in the order objectmatcher
: "eq" means "equals"value
: "credit_cards" is what we're looking for
- Action: When the condition is met, apply a 3% discount
type
: "percentage" indicates a percent-based discountselector
: "order" means apply to the entire ordervalue
: 0.03 represents 3%
Result
When a customer places an order and selects a credit card as their payment method, the system automatically applies a 3% discount to their entire order total. This discount is reflected in the final price shown to the customer.
The Rules Engine evaluates the order data, confirms that the payment source type matches "credit_cards", and then calculates and applies the appropriate discount amount without requiring any manual intervention or coupon codes.
Wrapping it up
The Rule Engine provides a very advanced framework for creating sophisticated promotional strategies. We believe it is one of the most powerful rules engine on the market today that offered as a core part of an ecommerce API. For new users, it will take a bit of time to understand what you can do to create targeted, effective promotions that drive new growth. But we will continue to post use cases that can be easily replicated by your team. The new engine provides powerful controls to take any promotional strategy to the highest level. And while the engine is powerful, it's also designed to be predictable and manageable. Anyone can start with simple rule combinations and gradually build up to more complex promotional scenarios as they become more comfortable with the system's capabilities.
For now, if you’re interested in using the Rules Engine, you need to be an enterprise customer. Please don’t hesitate to reach out. Contact our Sales team to learn more. Once the new Promotion Rules Engine is open for general availability, we’ll write a follow up blog post with more use cases as well as specific ins-and-outs for how the Rules Engine works. Stay tuned.
Was this post helpful? Let us know what you think by emailing us or joining our Discord channel by clicking on the module below this post. We are always here to help.
Good luck on your promotions.