This article is aimed at customers who edit and do more advanced CPC (Custom Price Calculation) configurations in XML and who wish to learn how to set up a fee condition. A fee condition is a condition that, if true, will be added to the final price.
The fee condition is specified in the XML node of the current indicator using compound operators, simple operators, and operands.
A condition can be added to indicators such as Fee, Discount, Service, GlobalIndicator, and Goodstype but in this article, we will explain how to configure fee conditions.
Go to:
The <FeeCondition> node
In CPC it is possible to specify a fee that is only applied if certain conditions are met. Conditions applied to the fee are always placed inside the <FeeCondition> node.
Example 1, shows a condition that is only applied if the package length is 80 cm or more.
Example1:
<FeeCondition>
<Length GreaterThanOrEqual="800" />
</FeeCondition>
Simple operators
Simple Operators are the mathematical operators used to check a condition. In example 1 above, we used the following operator: GreaterThanOrEqual.
Full list of simple operators:
- GreaterThan
- GreaterThanOrEqual
- LessThan
- LessThanOrEqual
- Equal
- NotEqual
- Contains
- NotContains
- In
- NotIn
Operands
Operands are the value in the shipment that is referred to. Example 1 used Length which refers to the length of the package.
The full list of operands:
- Width (mm)
- Height (mm)
- Length (mm)
- CodAmount
- Weight (kg)
- WxHxL (mm)
- Volume (mm3)
- DangerousGoods
- CarrierAccountNumber
- InputWeight
- CustomField
Compound operators
Compound operators can be <OR> or <AND> or a combination of both and defines whether all or just one of the conditions must be met. In Example 2, <AND> is used, which means that all conditions must be met. This means that all of the operands Width, Height, and Length must be at least 600mm (60cm).
Example 2: Condition where all must be met
<AND>
<Width GreaterThanOrEqual="600"/>
<Height GreaterThanOrEqual="600"/>
<Length GreaterThanOrEqual="600"/>
</AND>
The same conditions can be put inside the <OR> compound operator as in example 2, which means that just one of the conditions must be met. If either Width, Length, or Height is 600 mm (60cm) or more the condition will be true.
Example 3: Conditions where one must be met
<OR>
<Width GreaterThanOrEqual="600"/>
<Height GreaterThanOrEqual="600"/>
<Length GreaterThanOrEqual="600"/>
</OR
In Example 4 below, you will see a full <Fee> node with a <FeeCondition> node containing both <OR> and <AND> to create a more advanced condition. In this case, it means that either the length of the package must be 1200 mm (120 cm) or more, or at least 2 sides must be 600mm (60cm) or more. If this is true, a fee of 40 will be added to the price.
Example 4: Use of both compound operators
<Fees>
<Fee Name="Fee1" IndicatorType="Value" Order="100" IndicatorBasis="ToBaseValue">
<FeeEntryInterval ValueFrom="*" ValueTo="*">
<FeeValue RouteName="*" Value="40">
<FeeCondition>
<OR>
<OR>
<Width GreaterThanOrEqual="1200"/>
<Height GreaterThanOrEqual="1200"/>
<Length GreaterThanOrEqual="1200"/>
</OR>
<OR>
<AND>
<Width GreaterThanOrEqual="600"/>
<Height GreaterThanOrEqual="600"/>
</AND>
<AND>
<Height GreaterThanOrEqual="600"/>
<Length GreaterThanOrEqual="600"/>
</AND>
<AND>
<Width GreaterThanOrEqual="600"/>
<Length GreaterThanOrEqual="600"/>
</AND>
</OR>
</OR>
</FeeCondition>
</FeeValue>
</FeeEntryInterval>
</Fee>
</Fees>