You are here:
Implement Location-Based Pricing
Implement attribute-based pricing that evaluates a range of numeric values in an attribute or a field. Using this approach, you can override pricing for a product when, for example, the Quantity field on the line item exceeds a certain threshold or the numeric value of an attribute falls within a certain range.
- In Setup, find and select Custom Settings.
- Click the Custom Class Implementation custom setting.
- Click Manage and then click New.
- Enter the Name as CpqNgpCtxHydrationInterfaceHook. This is the Hook name.
-
Enter the Class Name as CpqNgpCtxHydrationInterfaceImpl
Here’s a sample custom class.
Sample Class :: Passing AccountShippingCountry to Order context. global class CpqNgpCtxHydrationInterfaceImpl implements System.Callable, devopsimpkg19.VlocityOpenInterface { global CpqNgpCtxHydrationInterfaceImpl() { } public Object call(String action, Map<String, Object> args) { Map<String,Object> inputMap = (Map<String,Object>)args.get('input'); Map<String,Object> outputMap = (Map<String,Object>)args.get('output'); Map<String,Object> options = (Map<String,Object>)args.get('options'); return invokeMethod(action, inputMap, outputMap, options); } public Boolean invokeMethod(String methodName, Map<String,Object> inputs, Map<String,Object> output, Map<String,Object> options) { System.debug('inside cpq hook interface'); System.debug('methodName ::: ' + methodName); System.debug('inputs ::: ' + JSON.serialize(output)); if( methodName.equalsIgnoreCase('hydratePricingContext.PostInvoke')) { System.debug('inside post hook interface'); Map<String, Object> result = (Map<String, Object>)output.get('pricingInputMap'); System.debug('result :: ' + result); if(result != null) { List<Object> orders = (List<Object>)result.get('Order'); if(orders != null) { for(Object orderObj : orders) { Map<String, Object> orderMap = (Map<String, Object>) orderObj; Order order = [SELECT Id, Account.ShippingCountry FROM Order WHERE Id =: (String) orderMap.get('CartId')]; orderMap.put('AccountShippingCountry', order.Account.ShippingCountry); } } } } System.debug('outputs ::: ' + JSON.serialize(output)); return true; } } -
Add AccountShippingCountry to the extended or cloned Context
Definition from the Standard Context Definition and update the context mapping. You can
either create a new context mapping by deleting the existing mapping, or
alternatively map this new field to one of the Order fields in the existing
context mapping.
-
From the App Launcher, find and select LookupTables.
- Click New.
- .From Lookup Table Type, select Decision Table.
- Click Next.
-
Specify the decision table details.
- Name: LocationBasedDM
- Type: Standard
-
Create a decision matrix version.
- From the App Launcher, find and select LookupTables.
- Click the link of the CMEAttributeBasedPricingDM decision matrix for which you're creating another version.
- On the record page of the matrix, on the Related tab, click New.
-
Enter a name and a version number for your
new decision matrix version.
For more information on how to create a decision matrix version, see Create a Version of a Standard Decision Matrix.
- Activate the decision matrix version.
-
Add the decision matrix to the active pricing
recipe.
- In Setup, find and select Pricing Recipes.
- Choose the recipe that you want to add to your lookup tables.
- On the Price Adjustment Matrix tab, click Modify.
- Select the LocationBasedDM lookup table.
- Select Price Component Type as Custom Discount.
-
Add the Price Adjustment Matrix pricing
element.
After the Price List element and before the Aggregate element, add a pricing element of type Price Adjustment Matrix. For more information on Price Adjustment Matrix, see Price Adjustment Matrix.
- Click Add elements icon, and select the Price Adjustment Matrix element from the list.
- In the Lookup Table Details field, search for and select your Custom Price Adjustment Matrix.
-
Map all your variables with the context
tags.
-
Save and activate the pricing procedure.
See Also: Setting Up RangeAttributePricingMatrix

