/
Comparing Item Cost to MSRP
Comparing Item Cost to MSRP
Comparing Item Cost to MSRP
This simple example will show you how to compare the item cost to the MSRP and perform conditional messaging to the customer. First we need to explain what we want to accomplish in psuedo logic
If the item has an MSRP (not null == true in Velocity) and the MSRP is less than the Cost then
display a message to the customer
else
display a different message to the customer
end
The following if/else statement performs the comparison:
#if ($item.getMSRPAsBigDecimal() && $item.getMSRPAsBigDecimal().compareTo($item.getCostAsBigDecimal()) < 0) Price Break... #else No Price Break... #end
Now let's put this together into a more complete example where we show the customer the math:
#if ($item.getMSRPAsBigDecimal() && $item.getMSRPAsBigDecimal().compareTo($item.getCostAsBigDecimal()) > 0) <del>$item.getMSRP()</del> <br/> - $item.getMSRPPriceBreak() <br/> $item.getCost() #else $item.getCost() #end
, multiple selections available,
Related content
Velocity Coding Example - Display Item Count and Total Conditional
Velocity Coding Example - Display Item Count and Total Conditional
More like this
Velocity Coding Example - Display Cart Total Conditional
Velocity Coding Example - Display Cart Total Conditional
More like this
Dollars Until Free Shipping Tutorial
Dollars Until Free Shipping Tutorial
More like this
Velocity Coding Example - Display Item Count Conditional
Velocity Coding Example - Display Item Count Conditional
More like this
Velocity Coding Example - Receipt Conditional Text From Item Attribute
Velocity Coding Example - Receipt Conditional Text From Item Attribute
More like this
Coding Example - Item with multiple option types
Coding Example - Item with multiple option types
More like this