I’m trying to have a template variable with the retail price and a template variable with the slashed price; is it possible to do some math on these numbers to find the percent discounted?
PHX has a math: modifier that I think would do it, but it would be much faster to just send the two TVs as parameters to a snippet and have the snippet do the math.
Something like this (untested):
Your discount is [[Discount? &retailPrice=`[*retailTV*]` &salePrice=`[*saleTV*]`]]%<br />
In the Discount snippet:
$diff = $retailPrice - $salePrice;
$discount = $diff/$retailPrice;
return($discount * 100);
This works perfectly for what I'm looking for. But how can I force it to round to nearest percent?
i'm getting 24.057738572574% when i need 24%