# Action: Apply Nested Price Rule

Use this action to nest another price rule within the current price rule. The current price rule will use the instructions in the nested price rule to set pricing. You can place the nested price rule on any path in the current price rule.

If there is a portion of a price rule that you can reuse in other price rules, then consider creating a separate price rule that contains only the reusable portion. Then you can nest this price rule in other price rules. For example, you could create a price rule that calculates base costs, and then nest that price rule in other price rules that mark up base costs different ways. You can nest price rules on different paths within the same price rule. By nesting price rules, you can reduce the time it takes to create and maintain a set of price rules. You can also make price rules less visually complex in the Price Rule Builder by tucking away some of the pricing instructions in nested price rules.

To simplify the descriptions in this topic, a price rule that contains a nested price rule is called a parent price rule.

## Example of nested price rule use

A store sells to customers in two regions: Region A and Region B. The cost of business is higher in Region B. For each region, the price manager wants to create a reusable price rule that determines base costs for catalog entries in the master catalog. Then he can nest these two price rules in any other price rules that use base costs as a starting point for pricing.

The pricing manager maintains the following price list on which all pricing for the store is based:

Base Cost – This is a list of all catalog entries along with their base cost for manufacturing and distribution. This list is for Region A, so the costs must be raised for Region B to account for addition cost of business.

1. The pricing manager creates the following two price rules:
"Base Cost for Region A" - This price rule uses the Base Cost price list as is:

"Base Cost for Region B" - This price rule uses the Base Cost price list, but then uses a price equation to add an uplift for Region B:

Each of these price rules can now be nested in other price rules that mark up base costs.

2. The pricing manager has a business contract that is assigned customers from both Region A and Region B. For this contract, he needs a price rule that can calculate prices for both regions. He creates a parent price rule that:
• Nests the "Base Cost for Region A" and "Base Cost for Region B" price rules
• Marks up the base costs by 30%

The price rule looks like this:

Note that in the previous price rule example, the bottom path uses pricing for Region B (the higher prices). Since this bottom path does not have a Customer Condition, any customers shopping under the contract who are not in either member group are entitled to Region B prices.

As new contracts come in, the pricing manager can nest the two base cost price rules in additional price rules as required. Any changes to the two base cost price rules will affect all price rules in which they are nested, making price rule maintenance easier.

## Example of using a nested price rule to call an ILOG JRules ruleset

If your site is integrated with IBM WebSphere ILOG JRules BRMS, you can specify an external price rule that references an ILOG JRules ruleset in the Apply Nested Price Rule action. If you do, you can combine HCL Commerce price rule elements with an external price rule, as shown in this example:

To create this kind of price rule, you must:

1. Create an external price rule that references an ILOG JRules ruleset for pricing.
2. Use the Price Rule Builder to create a price rule like the previous example, and specify the external price rule you created in step 1 in an Apply Nested Price Rule action.

## Guidelines for nesting price rules

1. Do not nest an independent price rule (a price rule that contains a price list) on a path that contains or receives input from another price list. If you do, HCL Commerce ignores all actions containing price lists except for the last action.

In the following example, Price rule B is not valid because it contains two price lists on the same path, as a result of nesting:

• 1 Price rule A contains the Base Cost price list.
• 2 Price rule B nests Price rule A; however, because the path in Price rule B contains another price list (Distribution Cost), HCL Commerce will ignore all actions containing price lists except the last action. This means that the Get Price from Price Rule action is ignored, and only the Apply Nested Price Rule action is used to determine pricing.
Actions that contain price lists are:
• Get Price from Price List action
• Calculate Price action, when used with a price equation that contains a price list.
2. Give the nested price rule a meaningful name that clearly states its function. This way, when you view a price rule in the Price Rule Builder that uses the nested price rule, you can read the name and understand its use. This is important because you cannot open a nested price rule directly from the price rule in which it is nested to see what it does.