/
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
PricingTier SFO
PricingTier SFO
More like this
Velocity Coding Example - Receipt Conditional Text From Item Attribute
Velocity Coding Example - Receipt Conditional Text From Item Attribute
More like this
Adding text to the checkout when a specific item is being purchased
Adding text to the checkout when a specific item is being purchased
More like this
Dollars Until Free Shipping Tutorial
Dollars Until Free Shipping Tutorial
More like this
Porting IfPurchased Tokens on the legacy receipt over to Velocity
Porting IfPurchased Tokens on the legacy receipt over to Velocity
More like this
Velocity Coding Example - Display Item Count and Total Conditional
Velocity Coding Example - Display Item Count and Total Conditional
More like this