Jump to content

Detecting zero values for Smarty currency variables


HancoEuropa

Recommended Posts

It is entirely possible I'm not very bright.

I can't figure out a better way of detecting a zero amount for the Smarty currency strings ....

This is what I'm doing (not very elegant!):

{if $service_first_payment_amount neq "£0.00" and $service_first_payment_amount neq "€0.00" and $service_first_payment_amount neq "0.00lei"} ...

It's just that the text strings don't help much ... What is the smart way to Smarty here? 

Thanks so much for any tips!

Link to comment
Share on other sites

  • 2 weeks later...
On 11/10/2020 at 10:12, HancoEuropa said:

It's just that the text strings don't help much ... What is the smart way to Smarty here? 

I take it from the variables, that this code is in an email template... so options are limited... and even more limited in v8....

if the above works for you then it's fine to use it...  I suppose a slightly shorter method would be to use in_array..

{if !in_array($service_first_payment_amount,array("£0.00","€0.00","0.00lei"))}

which says that if $service_first_payment_amount does NOT contain a 0.00 amount, then do something.

Link to comment
Share on other sites

Yes, sorry for not saying it was e-mail template, but you are correct Brian!

Yeah, my next step was an array ... could possibly make the array in advance in a hook based on all current currencies and merge that array variable into the $var for the template, would make updating alot easier when a currency is added/deleted later.

Suppose other way is if len <=5 and contains 0.00 or 0,00 ... but just as much work really. 

Thanks so much, most appreciated!

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated