Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

newbie question...conditional if with math

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
dave_mwi
Smarty n00b


Joined: 03 Jun 2003
Posts: 1

PostPosted: Tue Jun 03, 2003 4:09 pm    Post subject: newbie question...conditional if with math Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Jun 03, 2003 6:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP