Quote:
Originally Posted by totaltec
Aha! I think I see it.
Smarty cannot use non integer variables in a math equation. Since some of your variables are not assigned like w=$ordered1 then it returns null. "null" doesn't add up and breaks the math equation.
You can handle this several ways by assigning a value of 0 to ordered1 etc, or by using |default:0 which is my preference.
|
Brilliant! I was hoping it would just assume non intergers as 0, for purposes of math equations, but that obviously wasn't the case. Everything is working now. Thanks again.
Quote:
BTW, you also have a small typo: x=$orderedz5
|
THESE DAMN Z's!! I also noticed that it was outputting an unexpected number. Upon closer inspection:
Quote:
text{math equation="(( w * 9 ) + ( z * 18 ) + ( y * 18 ) + ( z * 18 ))" w=$ordered1 z=$orderedz5 y=$ordered6 z=$ordered7}
{else}
|
should have been:
Quote:
text{math equation="(( w * 9 ) + ( z * 18 ) + ( y * 18 ) + ( z * 18 ))" w=$ordered1 x=$orderedz5 y=$ordered6 z=$ordered7}
{else}
|
Hopefully that helps someone that comes along later.
P.S. for anyone that needs it, I added format="%.2f" to my code in order to display 2 decimal places (like you would need in the case of currency).
Code:
{math equation="(( w * 1.96 ) + ( x * 1.50 ) + ( y * 1.50 ) + ( z * 1.50 ))" w=$ordered1|default:0 x=$ordered5|default:0 y=$ordered6|default:0 z=$ordered7|default:0 format="%.2f"}