|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
dave_mwi Smarty n00b
Joined: 03 Jun 2003 Posts: 1
|
Posted: Tue Jun 03, 2003 4:09 pm Post subject: newbie question...conditional if with math |
|
|
I'm a newbie at smarty scripting and want to perform the following -- although I know in the format I'm posting this it doesn't work:
{if $cart.shipping_cost < (.06*$cart.sub_total)}
{$cart.shipping_cost = (.06*$cart.sub_total)}
{/if}
I tried putting in lt for the < sign, but that didn't work either...I'm a little confused when it comes to putting equations like this into a conditional and if I can even do it.
Thanks...
-----
Dave |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Jun 03, 2003 6:16 pm Post subject: |
|
|
Ideally you should keep this kind of application logic out of the templates. Let the templates deal with presentation, nothing more. In your case, adjust the value of $cart.shipping_cost in the application before template assignment.
To answer your question, this does not work:
{$cart.shipping_cost = (.06*$cart.sub_total)}
You'd have to do an assign with a math expression, something like:
{math equation="x * y" x=$cart.sub_total y=.06 assign=$cart.shipping_cost}
Monte |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|