tomb Posted September 9, 2015 Share Posted September 9, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 9, 2015 Share Posted September 9, 2015 try... {if $invoice_status eq "Paid"}<span class="label paid">Paid</span>{elseif $invoice_status eq "Unpaid"}<span class="label unpaid">Unpaid</span>{/if} 0 Quote Link to comment Share on other sites More sharing options...
tomb Posted September 9, 2015 Author Share Posted September 9, 2015 try... Brian, thank you. Yes, I was trying this combination too. However there’s a blank output. It doesn’t print anything!? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 9, 2015 Share Posted September 9, 2015 which email template are you trying to use it in? I think that mergefield will only be available in the invoice email templates, so you wouldn't be able to use in a general email template for example. 0 Quote Link to comment Share on other sites More sharing options...
tomb Posted September 9, 2015 Author Share Posted September 9, 2015 Yes, I am trying to use it on the "Invoice Created" email template only. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 9, 2015 Share Posted September 9, 2015 any errors in your activity log? 0 Quote Link to comment Share on other sites More sharing options...
tomb Posted September 9, 2015 Author Share Posted September 9, 2015 (edited) any errors in your activity log? no error shows up. It looks pretty normal. Although the output in the email template is empty. Edited September 9, 2015 by tomb 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 9, 2015 Share Posted September 9, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
tomb Posted September 10, 2015 Author Share Posted September 10, 2015 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? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 10, 2015 Share Posted September 10, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
tomb Posted September 10, 2015 Author Share Posted September 10, 2015 (edited) Status: {$invoice_status|strtoupper} and see what the output is. It worked like a charm! Tested with a paid and unpaid invoices. However how can I use it to style the output? Edited September 10, 2015 by tomb 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 10, 2015 Share Posted September 10, 2015 (edited) I assume you've tried putting <span> either side of it? don't forget you can enter the html directly using the HTML button. Edited September 10, 2015 by brian! 0 Quote Link to comment Share on other sites More sharing options...
tomb Posted September 10, 2015 Author Share Posted September 10, 2015 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 ;-) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 10, 2015 Share Posted September 10, 2015 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! 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. 0 Quote Link to comment Share on other sites More sharing options...
tomb Posted September 10, 2015 Author Share Posted September 10, 2015 that definitely works in v5.3.14 as i've just tested it! 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 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? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 10, 2015 Share Posted September 10, 2015 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! 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. 0 Quote Link to comment Share on other sites More sharing options...
tomb Posted September 13, 2015 Author Share Posted September 13, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 13, 2015 Share Posted September 13, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.