ShipHawk Guide

How To Create Rules Using OR Logic

Rules Overview

ShipHawk’s Rules Engine is a powerful tool to automate Rating, Packing, and Shipping decision making based on merchant-specific requirements.  Automated decision making reduces the errors, inconsistencies, and delays that are inherent in manual decision making. (For more information, see For more information, see Rating Rules and Shipping Policies .)

A Rule has two parts: Criteria and Actions

  • Criteria define conditions that must be TRUE for rules to apply.   

  • Actions define the behavior when the Criteria are TRUE. 

 A simple example of a Rating Rule is to offer Free Shipping on a certain day for orders over $50.  This rule would have two Criteria (Order Date and Order Value), and one Action (“apply free shipping” to the shipping cart).  

The ShipHawk Rules Engine supports a broad range of criteria and allows merchants to create rules using multiple criteria. Previously, the engine required all of the rule criteria to be TRUE (using AND logic) when evaluating whether the Action should be executed.  Now, merchants can create rules that evaluate when any of the rule criteria are TRUE (using OR logic), or a combination of both.

The “OR” logic operator 

ShipHawk’s Rules Engine now supports OR logic for Rules containing multiple Criteria.  Rules created using this logic will evaluate to TRUE when any (that is, one or more) of the criteria are TRUE:

Logical Operator

Description

AND

When All of the criteria are TRUE

OR

When Any of the criteria are TRUE

For example, consider the following scenario:

A merchant wants to offer free shipping for orders over $100 USD or free shipping to a specific set of ZIP codes near a warehouse.  Previously, merchants would have had to create and manage two separate Rules, one based on order value and one using ZIP codes.  Now, a single Rule can evaluate multiple criteria and apply the Action if any criterion is TRUE. 

Note that OR logic is available for Criteria but not for Actions because the Rules Engine would be unable to determine which Action to apply.  In these circumstances, two Rules should be used with Criteria to define which specific Action to take.

Creating a Rule with OR logic

To create a new Rule:

  1. Log  in to your ShipHawk account with Administrator privileges.  

  2. Select Settings > Rules to open the Rules view.  

  3. Next, select Action > Create New Rule:




    The Create New Rule window has a new field in the Rule Application section to select whether All or Any of the Criteria must be met. 

    The default setting when selecting criteria is All which matches the prior behavior when creating new Rules:



  4. Enter a new Rule Name and select a Rule Type.  

  5. In Rate Source, select the rate source as  API, Web Portal, or Any.

  6. To create a Rule with OR logic, select Only apply this rule when of the following criteria met (be sure to select Any rather than “All” from the drop-down).




  7. Next, click + ADD CRITERIA  multiple times to add multiple criteria.  Note the OR operator listed between the criteria.

  8. Select the field to evaluate (for example:  SKU, Destination State, Carrier Type, and so on), the Criteria operator for each (for example: starts with, is, contains, and so on) and enter the value (or values):




  9. Configure the RULE ACTIONS and click the CREATE button to save the Rule. 

 

Creating a Rule with Nested Criteria

Some situations call for more complex Rules where you might want to combine AND and OR criteria logic.  You can do this by clicking the + NESTED CRITERIA option to specify separate logic for a sub-group of criteria.

By default, the nested criteria will automatically apply the alternate logic from the primary criteria.  You can set the nested logic to the same operator as the main operator, but the logic will be the same as having all criteria at the same level.  The logical statement “A AND B AND C” is identical to “A AND (B AND C)”.

The following example above combines the AND and OR logic.  The Rule will be applied if the first criteria (SKU) AND either the second (Destination Contact Name) OR third criteria (Destination Country) are TRUE:

Best Practices for Creating Rules

  • Review Rating Rules and Shipping Policies for more information on configuring Rating Rules and Shipping Policies.

  • Simple Rules with fewest Criteria are recommended and easiest to manage.   Use OR logic when combining similar Rules such as Masking Carriers and Services and scenarios where you want to combine criteria operators.  For example: a Rule when “SKU starts with A” OR “SKU starts with B”.  

  • Simple Rules can improve troubleshooting as the Order History can display which rules have been applied to a given order.  Complex Rules with multiple criteria may be more difficult to troubleshoot or Rules applied to an order, so Simple Rules are recommended.

  • Many Criteria allow the user to specify multiple values for a given Criteria which functions similarly to an OR operator.  For example: if “Destination State” is one of “CT, MA, ME, NH, RI”.  Criteria operators that are similar to OR feature include:

    1. “one of”

    2. “not one of”

    3. “>”, “<”, “>=”, “<=”

    4. “Is between”

Limitations

  • Nested criteria are only available one level deep:

Valid logic:  A AND (B OR C) AND D

Invalid logic:  A AND (B OR (C AND D))

  • The OR function is not supported for Rule Actions.  When a Rule Criteria evaluates as TRUE, all Rule Actions will be applied.

https://shiphawk.force.com/success/s/article/How-To-Create-Rules-Using-OR-Logic

 

Contact Technical Support
© ShipHawk 2024. All Rights Reserved.