Jump to content

How to style {$invoice_status} field in E-Mail Templates?


tomb

Recommended Posts

Hi there,

 

I am trying to add some styling for the $invoice_status field in E-Mail Templates. Unfortunately my Conditional doesn't seem to be correct. What's the correct way to retrieve the status?

 

 

Here's my code

 

{if {$invoice_status} eq "Paid"}<span class="label paid">Paid</span>{/if}{if $invoice_status eq "Unpaid"}<span class="label unpaid">Unpaid</span>{/if}

 

 

Thanks for any help.

Link to comment
Share on other sites

I mentioned the activity log, because when I pasted my code into the template, I started getting smarty error in the activity log.

 

in the end, I removed the copy&pasted code and manually re-typed it - try typing it in again, perhaps without the spans and see if that works for you.

 

it works with v6.0.2 for me without the spans as i've tried on my v6 dev.

Link to comment
Share on other sites

Good point. I am using 5.3.14. I've spent some time with different combination.

 

Removing all tags and classes shows also empty output:

 

{if $invoice_status eq "Paid"} PAID {elseif $invoice_status eq "Unpaid"} UNPAID {/if}

 

 

Seems like a bug?

Link to comment
Share on other sites

Good point. I am using 5.3.14. I've spent some time with different combination.

Removing all tags and classes shows also empty output:

{if $invoice_status eq "Paid"} PAID {elseif $invoice_status eq "Unpaid"} UNPAID {/if}

Seems like a bug?

just copy&pasted the above into v5.3.14 and it works fine - well the PAID half works, I don't have an unpaid invoice to test against, but it should work.

 

as another test, try the following code in your email template instead:

 

Status: {$invoice_status|strtoupper}

and see what the output is.

Link to comment
Share on other sites

Yes, I've disabled the Rich Editor and than pasted the source code. Of course, Status: <span class="myclass“>{$invoice_status|strtoupper} </span> shows up correctly. However I’d like to add green for PAID, red for unpaid ;-)

there would be a few ways to do that - one might be going back to the earlier code...

 

{if $invoice_status eq "Paid"}<span style="color: #339966;">PAID</span>{elseif $invoice_status eq "Unpaid"}<span style="color: #ff0000;">UNPAID</span>{/if}

that definitely works in v5.3.14 as i've just tested it! :idea:

 

alternatively, you could shorten it a little...

 

<span class="{$invoice_status}">{$invoice_status|strtoupper}</span>

... but then you'd also have to define two new CSS classes (or use myclass and add IDs), "Paid" and "Unpaid", and give each one the formatting you want, e.g Green or Red etc.

Link to comment
Share on other sites

that definitely works in v5.3.14 as i've just tested it! :idea:

 

 

 

First off, I really appreciate your time and help. I was using the exact source code. And it’s not working for me!

The condition shows up correct within Rich Editor

 

RichEditor-condition.png

 

I've removed additional html code in the Invoice Created Email Template and I insert

 

{if $invoice_status eq "Paid"}<span style="color: #339966;">PAID</span>{elseif $invoice_status eq "Unpaid"}<span style="color: #ff0000;">UNPAID</span>{/if}

 

Result: Empty email output! Mail Encoding is set to 8bit. I've also removed Global Email Header and Footer Content. No error messages showing up in the Activity Log. Crazy. Any ideas?

Link to comment
Share on other sites

it is crazy - as try as I might, I can't make it fail here! :)

 

if I wipe my template, paste your code into the html box, it works... even tried using single quotes, and css colors, to make it fail - but it still works!

 

XGLR2An.png

 

a couple of things to try...

 

1. choose another email template, add a mergefield that you know will exist and apply some styling to it... then see if it sends and works...

 

2. if you're uncomfortable with this suggestion, don't do it... but you could paste the above code directly into the tblemailtemplates database table - in the 'message' column for the "Invoice Created" template - that would bypass the changes the form makes to the code when it adds it to the database.

 

I can remember having to do that with an earlier v5.3 release.

 

if you do that, don't press "Save Changes" on the form - just send yourself an invoice and see if it works... if it does, then the form is causing the error; if not, then we can look elsewhere.

Link to comment
Share on other sites

Brian, Thank you.

 

 

1. choose another email template, add a mergefield that you know will exist and apply some styling to it... then see if it sends and works...

 

 

Styling a merge field isn't a problem. Choosing another email template is working fine. However as soon as I use the condition from above, the invoice status isn't displayed.

 

 

 

2. if you're uncomfortable with this suggestion, don't do it... but you could paste the above code directly into the tblemailtemplates database table - in the 'message' column for the "Invoice Created" template - that would bypass the changes the form makes to the code when it adds it to the database.

 

It's still missing. ?

 

 

 

I guess it a Syntax problem within my html code. However I don't see any errors. I am already using another condition which is just working fine. For now I don't' want to spent more time on this. Thus I am going to focus on our WHMCS 6 migration.

 

Again I really appreciate your time you've spent on my issue. I'll let you know wether the condition is working on our v6 installation.

Link to comment
Share on other sites

Styling a merge field isn't a problem. Choosing another email template is working fine. However as soon as I use the condition from above, the invoice status isn't displayed.

actually, what I meant was to use the same code, but use another variable/mergefield to see it it worked in another template.

 

I guess it a Syntax problem within my html code.

I was thinking the same - i'm confident the smarty code is ok, so there must be something before it in the html code that isn't closed correctly or is preventing the {if} from working.

 

However I don't see any errors. I am already using another condition which is just working fine. For now I don't' want to spent more time on this. Thus I am going to focus on our WHMCS 6 migration.

 

Again I really appreciate your time you've spent on my issue. I'll let you know whether the condition is working on our v6 installation.

the chances are that it won't if you're importing your email templates and settings from a v5.3 database.

 

to test your smarty code on v6, you could always try the Admin Demo - you won't be able to modify the css,header or footer, but you can at least confirm that the smarty code would work in the email template.

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