This article explains what filtr rules are and how to set them in Ingrid Merchant Platform
Filter rules in Ingrid are used to define the behavior of the delivery options that Ingrid Delivery Checkout should produce for each checkout session.
Filter rules decide if Carrier Product or Delivery Category should be valid for showing delivery options. All rules validate the given statement and return a boolean response(True/False) for each rule. Based on if the full rule execution is True or False, the Category(or Carrier Method) is Shown(True) or "Not Shown"(False).
TIP: filter rules are the key to control the cases when you want to show/remove a delivery option in the Checkout. Consider all the various conditions when you want to remove a delivery offering from a Delivery Checkout widget. Be it a particular weight limitation, or a specific country zone or the size of the package (for example for the lockers products).
There are numerous functions in Ingrid available for you to adjust carrier product or delivery product and make a service available/unavailable for an end customer. Depending on the setup, please consider which of the above would benefit you. A carrier product could have two delivery types linked and the filter could affect both. A delivery category can be linked to a single or more carrier products, which gives us another option of control.
You might have a contract in place which requires from you to ship a product under 7kg. Let us have a look on how a solution for such scenario can be implemented.
1. From your Ingrid Merchant admin go to Delivery Checkout > Regions > Specific region
2. Select a specific Delivery Category or Carrier Product.
Note: Filter rule could be set on a delivery category or on a carrier product.
3. Set a filter rule in the "Filter rules section".
TIP: Mind the values of the dimensions and parameters you set the filter rules with. In Ingrid, we work with: grams, millimeters, and cents. It means:
Weight - should be defined in grams
Dimensions (Length, Width, Height) - in millimeters
Price / Values - Cent based (10.50 € = 1050)
Since the filter rules syntax is sensitive to potential typos and errors, it is highly recommended to first apply them on stage environment. Before publishing filter rule updates on prod, it’s best to check the Ingrid Checkout Widget test module within the Ingrid Merchant Platform first. If the session will return an error, it means that the filter rule most likely has a flaw. If you can’t find the root cause, feel free to consult our support team (email@example.com).
Filter rules present nearly unlimited possibilities of affecting the Ingrid session. Feel free to experiment on stage to find the most fitting scenarios. It’s also worth considering to use A/B Testing to find the most profitable conditions on prod.
Every filter rule is built with syntax. It can be a simple statement, limited only to one rule or an advanced, multi-level structure. The rules can work separately from each other, or be linked with operators. This can lead to filtering in and out certain services in a very elaborate context that suits your exact needs.
The filter rules can be linked with the following characters:
&& - AND statement
It creates a dependency under which every filter rule condition has to be met.
- total_weight <=30000 && all_cartitems_dims_sum_below(2500) && max_item_length < 1500
Total weight of the article must be lower than 30000 grams AND all their dimension sums has to be below 2500 milimeters AND no item can be longer than 1500 milimeters.
- not(contains(cart_items_attributes(), 'bulky')) && contains(cart_items_attributes(), 'light')
The cart item can’t contain an attribute ‘bulky’ AND must contain an attribute ‘light’.
I| - OR statement
It creates a dependency under which at least one fulter rule condition has to be met.
- in_range(postal_code(), 55302, 56636) || in_range(postal_code(), 58128, 59077)
The postal code has to be either in range between 55302-56636 OR in range between 58128-59077.
Both of these operators can be mixed within one sentence:
not(contains(cart_items_attributes(), 'Example')) && in_range(postal_code(),13025,13025) || in_range(postal_code(),13033,13034) || in_range(postal_code(),13036,13036)
The item in the cart cannot have an attribute “not-in-stock”, as well as the user can’t be located within the different postal code ranges.
There are two ways to alter the stated conditions within the syntax:
- By adding “not” in front of the condition, you can create a negative statement. For example, instead of creating a list of “positive” zip code ranges, you can pick this specific one that won’t be available for the service:
not(in_range(postal_code(), 11120, 12010))
It’s also useful with any different filter rule, counting the attribute-based ones:
- By adding an exclamation mark “!” in front of the condition, you can overturn the conditions to work in an opposite way. It’s best to describe it on example:
If all the cart items are above 68000 grams, the carrier option will be shown.
This overturn can be used within the sentence:
all_cartitems_below_weight(68000) && !all_cartitems_below_weight(18000)
If all the cart items will be below 68000 grams and above 18000 grams, the service will be shown.
matches_any_pattern(base, pattern 1, ... , patterN)
// Reports whether at least one pattern matches the base argument.
// For pattern should be used Glob syntax (more info about Glob syntax)
'*' - matches any sequence of characters.
'?' - matches any single character
'[123aB]' - matches one character given in the bracket
'[0-6]' - matches one character from the range given in the bracket
All rules validate the given statement and return a boolean response(True/False) for each rule. Based on if the full rule execution is True or False, the Category(or Carrier Method) is Shown(True) or "Not Shown"(False).