Jump to content

Conditionals on Invoice e-mail


maxihost

Recommended Posts

Hello,

 

I would like to create a conditional on invoice template like this,

 

{if $invoice_total bigger than "1000"}

Please pay using this payment method

{else}

Please pay using paypal

{/if}

 

In other words, if the invoice total is bigger than 1000 I would like to display one payment method, and if not, I will display paypal link. But it seems that WHMCS is not accepting "bigger than". What can I use instead ?

 

Thank you.

Link to comment
Share on other sites

if would be 'greater than' - so you would use > or gt

 

{if $invoice_total > "1000"}

Please pay using this payment method

{else}

Please pay using paypal

{/if}

 

however, I don't know if you can do this as $invoice_total contains both the currency symbol (if used) and the amount (e.g., $1000.00) - so even if you remove the currency symbol, i'm unsure whether it would be treated as a number.

 

but try the above code and see if it works.

Link to comment
Share on other sites

if would be 'greater than' - so you would use > or gt

 

 

 

however, I don't know if you can do this as $invoice_total contains both the currency symbol (if used) and the amount (e.g., $1000.00) - so even if you remove the currency symbol, i'm unsure whether it would be treated as a number.

 

but try the above code and see if it works.

 

It does not. I contacted WHMCS and they said I need to use Hook to do this. I asked if they create the hook for me as customized job but they are not doing at the moment. If you are able to do so, I would be interested in this job.

 

"Hi,

 

The variable you are trying to use is not an integer and so you cannot compare it as such. The value will always contain the currency prefix and suffix.

 

You can however create your own variable to be used on using the EmailPreSend hook point.

 

http://docs.whmcs.com/Hooks:EmailPreSend

 

You can check that the email template name is one you wish to use the variable on, and then the relid would be the invoiceid and you can obtain the balance from tblinvoices and create your own variable to run this comparison on."

Link to comment
Share on other sites

You can try with the code below. It's not pretty, but simple and should work good in this case:

 

{if $invoice_total|regex_replace:"/[^0-9.]+/":"" > 1000}
    Bigger than 1000
{else}
    Equal or lower than 1000
{/if}

 

Worked pefectly. I just changed ">" to "gt" because I had an error whilw trying to send the invoice.

 

Thank you so much.

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