WebSphere Commerce EnterpriseIntroduced in Feature Pack 2

Price rule element template definitions

The conditions and actions used in price rules are based on templates. The templates are called price rule element template definitions. If you are customizing a condition or action, you must understand the purpose and structure of these template definitions before you modify an existing template or create a new one.

In the Price Rule Builder palette, each condition and action that a business user can add to a price rule is a price rule element. Price rule element template definitions define the blueprint for price rule elements. Each price rule element in the palette is associated to one template definition. For example, the Catalog Condition element is associated to the catalogCondition element template.

Price rule element template definitions are created in XML. This XML is called the runtime XML and its purpose is to:
  • Specify the unique name of the price rule element.
  • Specify the task command for the price rule element.
  • Specify the price rule element template parameters to pass to the task command, if required:
    • For a condition element, the parameters define the criteria for the condition. For example, a condition can require a customer to belong to the Tier A member group. If the condition is met, the task command will return true.
    • For an action element, the parameters define what to do, for example, get a price from a price list or apply rounding to a price.

Where element template definitions are stored

Table: PRELETEMPLATE

The runtime XML is stored in the RUNTIMEXML column.

Format of price rule runtime XML

The runtime XML must use the following format:

<FlowElementImplementation type="UNIQUE_NAME">
    <Implementation invocationType="TaskCommand">
        <Class name="TASK_COMMAND_CLASS_NAME">
                <Argument name="paramName1" value="PRICERULE_paramValue1"/>
                <Argument name="paramName2" value="paramValue2"/>
        </Class>
    </Implementation>
</FlowElementImplementation>

Parameters in price rule runtime XML

The following list describes the parameters that the runtime XML can contain (use the sample above as reference):

type
This is the unique name of the price rule element template for this condition or action.
invocationType
This value is always TaskCommand.

For the <Class> element: Each condition and action has an associated task command. This must be a class that implements the com.ibm.commerce.price.rule.commands.element.PriceRuleElementCmd interface and extends the com.ibm.commerce.price.rule.commands.element.PriceRuleElementCmdImpl class.

name
This is the name of the price rule element task command class for this price rule element. If you are creating a new condition or action, then whatever name you specify here must match the name of the custom task command you create to support the new price rule element. Here is an example:
com.your_company_name.commerce.price.rule.commands.element.CustomNewRegisteredConditionElementCmd

For the <Argument> element: The runtime XML can have zero or more of these price rule element template parameters. For each condition or action element in a price rule, the pricing services pass the parameters to the price rule element task command. The task command retrieves the parameters using the getElementParameters method and then uses the parameters to evaluate the condition or perform the action.

name
This is the name of the parameter that must be passed to the task command for processing so that the condition or action can do its work.
value
This is the value of the parameter. If the parameter value is coming from the user interface, then the value must be in the format PRICERULE_paramName. If the parameter value is coming from somewhere other than the user interface, then the value does not need the PRICERULE_ prefix.

Example

Here is an example of the runtime XML for a custom condition. This condition checks whether a customer registered on, before, or after a specific date:

<FlowElementImplementation type = "RegistrationTimeCondition">
    <Implementation invocationType = "TaskCommand">
        <Class name = "com.mycompany.commerce.price.rule.commands.element.RegistrationTimeConditionElementCmd">
            <Argument name = "registrationTime" value = "PRICERULE_registrationTime"/>
            <Argument name = "registrationTimeOperator" value = "PRICERULE_registrationTimeOperator"/>
        </Class>
    </Implementation>
</FlowElementImplementation>