Rules & Mappers - Using Rules Engine PDF

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Summary

This document gives an overview of Configured Commerce's rules engine components and rule types. It details persona rule types, user custom properties, and comparison operators. The document is likely a technical guide or reference document for developers or administrators.

Full Transcript

Rule types by context An overview of Configured Commerce's rules engine components and Rule Types. Suggest Edits Persona rule types A persona is built on the user and customer characteristics that you add to a persona rule. You select these characteristics from groups of similar char...

Rule types by context An overview of Configured Commerce's rules engine components and Rule Types. Suggest Edits Persona rule types A persona is built on the user and customer characteristics that you add to a persona rule. You select these characteristics from groups of similar characteristics like the data fields on the Customer screen. You can also use characteristics outside of the Admin Console like the shopper's location. The groups of similar characteristics appear in the Rule Type drop down field in the Rules Tab. When you choose a Rule Type the remaining fields in the Rule Tab are updated to display only the fields you need to complete for that Rule Type. The following tables list each Rule Type and the data fields that must be completed to build the persona rule. User Custom Properti es Custom This text box is used to determine the User Custom Property that Property the rule will attempt to compare using the Comparison Operator Name and Value Compari This drop-down is used to select the comparison criteria. The son options are: Equals, Not Equals, Less Than, Less Than or Equals, Operator Greater Than, Greater Than or Equals, Matches, Range, List This text box will hold a value that the Comparison Operator will Value attempt to resolve against An And/Or option that is used to determine if the rule is intended Conditio to resolve in addition to other rules, or if it is supposed to resolve n true in an either/or case Custo mer Fields Criteria This drop-down is used to determine the Criteria Property that the Propert rule will attempt to compare using the Comparison Operator and y Value Compa This drop-down is used to select the comparison criteria. The rison options are: Equals, Not Equals, Less Than, Less Than or Equals, Operat Greater Than, Greater Than or Equals, Matches, Range, List or This text box will hold a value that the Comparison Operator will Value attempt to resolve against An And/Or Option that is used to determine if the rule is intended Conditi to resolve in addition to other rules, or if it is supposed to resolve on true in an either/or case Distance from a Point Location This text box is used to enter an address that will be translated Phrase into a specific Latitude and Longitude by Google Maps This text box is used to determine the Latitude for the origination Latitude point of this rule Longitud This text box is used to determine the Longitude for the e origination point of this rule This selector is used to determine if the distance is intended to Within/O be within the area originating from the geographic location, or utside outside of that area This text box and selector is used to determine the numerical Distance distance from the origination point this rule will resolve true for, and if that distance is in Kilometers or Miles An And/Or Option that is used to determine if the rule is Conditio intended to resolve in addition to other rules, or if it is supposed n to resolve true in an either/or case Customer Custom Propertie s Custom This text box is used to determine the Customer Custom Property Property that the rule will attempt to compare using the Name Comparison Operator and Value This drop-down is used to select the comparison criteria. The Comparis options are: Equals, Not Equals, Less Than, Less Than or on Equals, Greater Than, Greater Than or Equals, Matches, Range, Operator List This text box will hold a value that the Comparison Operator Value will attempt to resolve against An And/Or option that is used to determine if the rule is Condition intended to resolve in addition to other rules, or if it is supposed to resolve true in an either/or case Curren t Locati on This drop-down is used to determine the property type for the Criteria Location Criteria. The options available are: City, Propert Country/Abbreviation, IDString, Latitude, Longitude, PostalCode, y StateAbbreviation. Compa This drop-down is used to select the comparison criteria. The rison options are: Equals, Not Equals, Less Than, Less Than or Equals, Operat Greater Than, Greater Than or Equals, Matches, Range, List or This text box will hold a value that the Comparison Operator will Value attempt to resolve against An And/Or option that is used to determine if the rule is intended Conditi to resolve in addition to other rules, or if it is supposed to resolve on true in an either/or case Authe nticat ed This checkbox is used to check and see if the user has been Value authenticated. An And/Or option that is used to determine if the rule is intended to Condit resolve in addition to other rules, or if it is supposed to resolve true ion in an either/or case Rules engine components Rule manager RuleManager is the container class that is attached to Entities to allow that Entity to have a RulesEngine, you define 0 or 1 RuleManager per instance of an Entity. For example, you may have several different Persona's and you create a RuleManager for each Persona and define the RuleClauses inside that RuleManager that makes the current user qualify to be of that Persona. Another example is for each different Carrier, you define a RuleManager that makes the current order qualify to be shipped using that Carrier. Rule clauses RuleClause defines the actual rules to be run and the Condition, Grouping, and Order in which they run. CriteriaType is always copied from the CriteriaType in the RuleTypeOption selected for the RuleClause. Depending on the CriteriaType, CriteriaObject and CriteriaProperty may be copied from the RuleTypeOption, if they are copied, then they would not be selectable in the UI. The other properties are set by the user in the UI. Rule type RuleType contains the allowed rules defined for a RuleManager's RuleClauses. Persona – used to assign a person in context within the site context. This is determined on initial access to the site, on sign-on and when the shipping address changes. Category – this is used by the Dynamic Category feature to determine the rules for a given category from which it determines which products to assign it Shipping – this is used by the Shipping Engine for an order to determine which carriers and carrier/services are available to the user based mostly on location and product information Promotion – this is used by the Promotion Engine to determine which promotions are available to an order. RuleType and its collection of RuleTypeOptions are the definitions for the UI for the available RuleClauses that a user can add to a RuleManager. For example, in the Admin Console you can create a RuleType for Personas. In that RuleType you can add RuleTypeOptions for the Customer object allowing a RuleClause to be created allowing the user to select any field from the Customer and compare the value or range of values of that field. What the RuleTypeOption allows/validates is based on the ICriteriaType the user chooses for that RuleTypeOption. Rule type option RuleTypeOption defines the rules that are available when adding a RuleClause, the RuleTypeOption for example might be defined that the Criteria Type is Object and the CriteriaObject is Customer and the CriteriaProperty is All Properties, then, when adding a RuleClause, in the UI it would generate the screen such that the user can select one of the properties from the Customer object and compare it's value. The CriteriaType must match the DisplayName field of a registered ICriteriaType. CriteriaTypeBase The base class for all criteria type's. ICriteriaType ICriteriaType implementations get registered in the IOC container and their DisplayName properties populate the drop down to select a CriteriaType for a RuleTypeOption. These classes are the main drivers for the Rules Engine, the Validate method is called returning true to indicate the rule passes or false if the rule fails. Example Allows creating rules to check values of entity properties. Requires an instance of the entity being checked to be passed in to the rules engine list of context objects. RulesEngine The concrete implementation and generic Rules Engine for Configured Commerce. Both the Execute and ValidateRule methods in RulesEngine class are defined as virtual. This means that when creating a new RulesEngine it might be beneficial to derive from the RulesEngine base class. Execute method Executed the rules and returns the pass or fail result as a Boolean. The input object must have an associated RuleManager object. If the RuleManager is null then a result of true is returned because default objects might not have any associated rules. If a RuleManager is available then the RuleClauses property of the RuleManager is used to then iterate through the rule groups and processes the conditions. ValidateRule method Validates one of the rule clauses by calling the appropriate CriteriaType's implementation of the validate method. It first retrieves the valid ICriteriaType object using the CriteriaTyepFactory. The enumerable context is then interrogated to find a context object with a type that matches the object type required for the current RuleClause. If no context is found then the RuleClause is validated without any context. IRulesEngine The RulesEngine.Execute method gets passed in to it the entity containing the RuleManager and a list of objects that contain the context information (like CustomerOrder, UserProfile etc.) that the RuleClauses will validate against. Field level data The following will define those fields that are not obvious. This is from a data perspective - the next section will define how to implement the UI. Table/Field or Description Property CriteriaType Note that these fields are not in the database DependencyNa This is an attribute of the class and is used to identify the me class in RuleTypeOption and RuleTypeClause This is used to define a specific entity that will be used to LookupObject find a single instance of the entity and embed it's Guid (ID) into RulesClause.SimpleValue. This is the fixed object that must be passed into the rule in order to evaluate the logic. This is used extensively for CriteriaObject CustomerOrder-specific rules for Shipping and Promotion engines. DisplayName This is what will display as the criteria in the UI RequiresCriteria This Boolean indicates if the UI needs to prompt for the Object criteria object itself. Currently, this is only set to True for Object and CustomProperty criteria. This and CriteriaObject are mutually exclusive - only 1 should be selected in a class but neither needs to be selected if the criteria can be evaluated without a specific object passed in (i.e. context objects) RequiresCriteria Boolean to define for prompting of the CriteriaPriorty in Property the RuleTypeOption RequiresCriteria Boolean to define for prompting of the CriteriaValue in Value the RuleTypeOption CriteriaValueLa This should become obsolete - it is superseded by the bel parameter descriptions Boolean to define if a data type will need to be defined for the CriteriaValue - this should mostly be obsolete since RequiresValueTy the Custom Properties are now aware of their types. pe Authenticated still may need this but we'll try to eliminate that as well. RequiresGeoCo Boolean to define if this is a distance-related rule de This is used to define the specific comparison values that are valid in the UI. If nothing is specified, all comparisons ValidRuleClause are available. Examples below: ComparisonOpe rators RuleClauseComparisonOperator.Equals, RuleClauseComparisonOperator.NotEquals Examples below - this is used to explicitly define the parameter values that can be acquired through the UI. This will override the values above and Parameter Descriptions { nameof(RuleClause.SimpleValue), new CriteriaTypeParameter { Label = "Category" } }, { nameof(RuleClause.CriteriaValue), new CriteriaTypeParameter { Label = "Quantity or Amount", PossibleValues = new[] { "quantity", "amount" } } }, { nameof(RuleClause.ValueMinimum), new CriteriaTypeParameter { Label = "Minimum Value" } }, { nameof(RuleClause.ValueMaximum), new CriteriaTypeParameter { Label = "Maximum Value" } } RuleTypeOption This is used in the rule clause dropdown to select a rule Description to configure This is a pointer back to the CriteriaClass plugin using the CriteriaType DependencyName from the class This is an optional field defining the object to use when applying the criteria. The criteria itself defines if this is captured (i.e. Object, CustomProperty) while most CriteriaObject criteria types define this internally. This currently only applies to CriteriaTypes Object and CustomProperty. This field is optional and used differently depending on the nature of the criteria type and is prompted for only if the CriteriaType itself indicates RequiresCriteriaProperty. CriteriaProperty If the criteriatype is Object, then this will define a specific property of the CriteriaObject or "All Properties" meaning that the RuleClause can pick it. If there is a 'secondary parameter' required or a custom property, this allows the user to select the type of data to ValueType acquire in the rule clause. Valid values include String, Decimal, Boolean, and Date) RuleManager This is the name of the RuleType for readability - the Name RuleTypeId is actually the referential link from the RuleType to the RuleManager RuleClause This defines a group of rules that have to be evaluated ExecutionGroup together to get a single Boolean value. Consider this a way to add parenthesis to the logical test This is the sequence in which the rules are evaluated ExecutionOrder within a group The valid values are AND and OR. The condition applies to the "next" rule clause, so if this is the last entry in a Condition group, the logical applies to the next group or individual rule. This is a pointer to the actual CriteriaType class and embeds the DependencyName field into the database as CriteriaType a reference - this is duplicated from the RuleTypeOption for performance This is the object that will be used to apply the test against the rule. CriteriaObject If the CriteriaType defines RequiresCriteriaObject = true, then it comes from the RuleTypeOption.CriteriaObject, otherwise it comes from CriteriaType.CriteriaObject. This field can be empty. This stores the specific object property selected if the criteria type is "Object" and used to store the custom property if the criteria type is "Custom Property". CriteriaProperty For CustomProperty it used to store the entity containing the custom property (i.e. ProductProperty, CustomerProperty) but since all custom properties are in the same place, we decided to move the custom property name into the CriteriaProperty field. This field also stores the "geolocation string" if the CriteriaType defines RequiresGeoCode = true. This stores an "additional value" that must be acquired from the user. CriteriaValue This is driven from the CriteriaType Dictionary if the CriteriaValue is included. An example will be "Distance From a Point" has to capture whether the distance (simple Value) is "Miles" or "Kilometers" These are defined as enums and includes: Equals Not Equals LessThan LessThanOrEqual GreaterThan ComparisonOpe GreaterThanOrEqual rator Matches (a regex expression) Range (prompts for min and max values) List (prompts for a comma-separated list) Contains (better descriptor than 'equals') DoesNotContain (better descriptor than 'not equals') This is the simple value entered for the rule - it is typically SimpleValue a Guid for a lookup or the key value to compare to (i.e. Date >= mm/dd/yy) If the ComparisonOperator = List, then this becomes a list of values that the system will use to look up valid ValueList values - this will only work for simple string or number values - it cannot be a list of guids This is used if the ComparisonOperator = Range or for ValueMinimum lookups with a secondary value - it is a string value and numbers/dates can be used This is used if ValueMinimum is being used - it is the ValueMaximum upper bound of the range Rule type options Updated 7 months ago FollowNot yet followed by anyone Rule types let you customize the rules applied to dynamic categories, promotions, personas, and shipping rules, as well as define custom rule types. Optimizely Configured Commerce contains four collections of rule types. However, you can create other types to meet specific business needs. Users can create custom rule types and rule type options to further use the Rules Engine. Custom development may be required to employ added Rule Types and Rule Type Options. Configured Commerce has multiple rule types by default: Badge Category Product Restrictions Product Visibility Promotion Shipping WishList Each rule type has a combination of rule type options. These options define the "IF" statement of the rule. You can create new rule types and rule type options in the Admin Console. These require custom development to assign the rule types to the entity. To use custom properties in the rules engine, add a Custom Property Rule Type option for the desired rule type in Administration > Rule Types. Valid rule type options Below is a list of valid rule type options. Although other rule type options may be visible, they do not create valid rule type option without custom development. Badge Product Custom Properties Product Fields Category Product Custom Properties Product Fields Product Restrictions Product Fields Product in Category Product in Warehouse Product from Vendor Product in Category Branch Product Visibility Customer Ship To Fields Customer Bill To Fields Promotion Authenticated Current Persona Customer Custom Properties Customer Order Custom Properties Customer Fields Customer Order Fields Order Bill To Order Carrier Services Order Currency Order Product Order Product From Category Order Product With Product Code Order Product From Vendor Order Line Count Order Product Total Order Contains/ Does Not Contain a Promotion Order Shipping Weight Order Ship To Country Order Ship To State/Provence Order Total Promotion Maximum Times Used Per Customer Promotion Maximum Times Used Requested Ship Date Is Day of Week Shipping Current Persona Customer Custom Properties Customer Order Custom Properties Customer Fields Customer Order Fields Order Products Order Products From Category Order Product From Product Code Order Product from Vendor Order Line Count Order Product Total Order Ship Weight Order Ship To Country Order Ship To State/Province Requested Ship Date is Day of Week WishList Product Fields Product Attributes Product Custom Properties Create a rule type 1. Go to Admin Console > Administration > Rule Types. 2. Click Add Rule Type. You can edit existing rule types and add additional rule type options to them. 3. Enter the name of the Rule Type. 4. Click Save. Now that a Rule Type is created, the next step is to add Rule Type Options to Rule Type. Create rule type options 1. Go to Admin Console > Administration > Rule Types. 2. Click Edit on the Rule Type. 3. Click the Rule Options finger tab. 4. Click Add Rule Type Options. 5. Add a description of the Rule Type Option. 6. Select the Criteria Type from the drop-down list. a. Criteria Types are coded plug-ins and define the rules around a particular rule type option. The intent is to allow the user interface to be derived automatically from the criteria type so that partners can develop additional rules without having to modify the user interface. 7. When applicable, select the Criteria Object and Criteria Property from the contextual drop-down lists. Selecting Object as a Criteria Type, will provide a super-set of all Criteria Objects available - it is up the Implementer to ensure that the Criteria Object is available at the time a rule is being invoked. 8. Click Save.

Use Quizgecko on...
Browser
Browser