lcws Posted October 4, 2015 Share Posted October 4, 2015 Hi all I am hoping someone can help, we process credit cards three days before the invoice due date and I am trying to ensure that the correct date that we are going to charge the card is displayed The default template is below. Dear {$client_name}, This is a notice that an invoice has been generated on {$invoice_date_created}. Your payment method is: {$invoice_payment_method} Invoice #{$invoice_num} Amount Due: {$invoice_total} Due Date: {$invoice_date_due} Invoice Items {$invoice_html_contents} ------------------------------------------------------ Payment will be taken automatically on {$invoice_date_due} from your credit card {$client_cc_type} ending in {$client_cc_number}. To update or change the credit card details we hold for your account please login at {$invoice_link} and click Pay Now then following the instructions on screen. {$signature} I need to be able to subtract 3 days for example date due October 6th I need it to say "Payment will be taken automatically on October 3rd...." does anyone know how to accomplish this like {$invoice_date_due} - 3 days? Thanks Stephen Link to comment Share on other sites More sharing options...
brian! Posted October 4, 2015 Share Posted October 4, 2015 Stephen, there are a few ways to do this, but if you want to do it in the email template using Smarty, you can try this... {math equation="x - y" x=$invoice_date_due|strtotime y=259200 assign="payment_date"} {$payment_date|date_format:"%d/%m/%Y"} you can split the lines up if you wish - the first creates a new variable of $invoice_due_date - 3 days and assigns it to $payment_date; the second just displays the new variable - so move that to wherever you want it in the email template. what you will probably need to do is play with the date_format options to match your existing date format. you didn't state which version of WHMCS you are using, so the above should work in both - it works in v6.1 for sure. Link to comment Share on other sites More sharing options...
lcws Posted October 6, 2015 Author Share Posted October 6, 2015 Thanks, I am using 6.1 I inserted the entire code where I want the date to display I am getting "Email Sending Failed - Message body empty" when attempting to send the email Dear {$client_name}, This is a notice that an invoice has been generated on {$invoice_date_created}. Your payment method is: {$invoice_payment_method} Invoice #{$invoice_num} Amount Due: {$invoice_total} Due Date: {$invoice_date_due} Invoice Items {$invoice_html_contents} ------------------------------------------------------ Payment will be taken automatically on {math equation="x - y" x=$invoice_date_due|strtotime y=259200 assign="payment_date"} {$payment_date|date_format:"%d/%m/%Y"} {$invoice_date_due} from your credit card {$client_cc_type} ending in {$client_cc_number}. To update or change the credit card details we hold for your account please login at {$invoice_link} and click Pay Now then following the instructions on screen. {$signature} What am I doing wrong? Thanks, I really appreciate your help Stephen Link to comment Share on other sites More sharing options...
brian! Posted October 6, 2015 Share Posted October 6, 2015 Hi Stephen, I just pasted your template code to the bottom of our v6.1 dev "Invoice Created" template and it worked - it shows the following... Payment will be taken automatically on 27/09/2015 30th September 2015 from your credit card ending in . the test client I used didn't have a cc card, so I don't mind that being blank; also, you may need to split the two Smarty functions up (1st can go anywhere above where the new variable is being called) to make the output flow better... and I assume the payment date and due date being together is just for testing... try the following... Dear {$client_name}, This is a notice that an invoice has been generated on {$invoice_date_created}. Your payment method is: {$invoice_payment_method} Invoice #{$invoice_num} Amount Due: {$invoice_total} Due Date: {$invoice_date_due} Invoice Items {$invoice_html_contents} ------------------------------------------------------ {math equation="x - y" x=$invoice_date_due|strtotime y=259200 assign="payment_date"} Payment will be taken automatically on {$payment_date|date_format:"%d/%m/%Y"} {$invoice_date_due} from your credit card {$client_cc_type} ending in {$client_cc_number}. To update or change the credit card details we hold for your account please login at {$invoice_link} and click Pay Now then following the instructions on screen. one possible cause of your issue may be if the code pasted into the template form has been modified on submission to the database - a quick way to check would be to hit the "edit html source" button (top right next to the ? button) and see if WHMCS has added any unusual code. also, the activity log might give you a clue to what it didn't like with the template content. Link to comment Share on other sites More sharing options...
lcws Posted October 10, 2015 Author Share Posted October 10, 2015 Still getting message failed error when testing out, here is what the activity log says can't find the mentioned error anywhere Email Sending Failed - Message body empty (User ID: 2 - Subject: Customer Invoice) Smarty Error: Syntax error in template "mailTemplate:plaintext" on line 1 "<span style="font-family: Courier New;"><span style="color: #0000bb;">Dear </span><span style="color: #007700;">{</span><span style="color: #0000bb;">$client_name</span></span><span style="font-family: Courier New;"><span style="color: #007700;">},<br /><br /></span><span style="color: #0000bb;">This is a notice that an invoice has been generated on </span><span style="color: #007700;">{</span><span style="color: #0000bb;">$invoice_date_created</span></span><span style="font-family: Courier New;"><span style="color: #007700;">}.<br /><br /></span><span style="color: #0000bb;">Your payment method is</span><span style="color: #007700;">: {</span><span style="color: #0000bb;">$invoice_payment_method</span></span><span style="font-family: Courier New;"><span style="color: #007700;">}<br /><br /></span><span style="color: #0000bb;">Invoice </span></span><span style="font-family: Courier New;"><span style="color: #ff8000;">#{$invoice_num}<br /> </span><span style="color: #0000bb;">Amount Due</span><span style="color: #007700;">: {</span><span style="color: #0000bb;">$invoice_total</span></span><span style="font-family: Courier New;"><span style="color: #007700;">}<br /> </span><span style="color: #0000bb;">Due Date</span><span style="color: #007700;">: {</span><span style="color: #0000bb;">$invoice_date_due</span></span><span style="color: #007700;"><span style="font-family: Courier New;">}<br /><br /></span></span><span style="font-family: Courier New;"><span style="color: #0000bb;">Invoice Items<br /><br /></span><span style="color: #007700;">{</span><span style="color: #0000bb;">$invoice_html_contents</span></span><span style="font-family: Courier New;"><span style="color: #007700;">} <br /> ------------------------------------------------------<br /><br />{</span><span style="color: #0000bb;">math equation</span><span style="color: #007700;">=</span><span style="color: #dd0000;">"x - y" </span><span style="color: #0000bb;">x</span><span style="color: #007700;">=</span><span style="color: #0000bb;">$invoice_date_due</span><span style="color: #007700;">|</span><span style="color: #0000bb;">strtotime y</span><span style="color: #007700;">=</span><span style="color: #0000bb;">259200 assign</span><span style="color: #007700;">=</span><span style="color: #dd0000;">"payment_date"</span></span><span style="font-family: Courier New;"><span style="color: #007700;">}<br /></span><span style="color: #0000bb;">Payment will be taken automatically on </span><span style="color: #007700;">{</span><span style="color: #0000bb;">$payment_date</span><span style="color: #007700;">|</span><span style="color: #0000bb;">date_format</span><span style="color: #007700;">:</span><span style="color: #dd0000;">"%d/%m/%Y"</span><span style="color: #007700;">} {</span><span style="color: #0000bb;">$invoice_date_due</span><span style="color: #007700;">} </span><span style="color: #0000bb;">from your credit card </span><span style="color: #007700;">{</span><span style="color: #0000bb;">$client_cc_type</span><span style="color: #007700;">} </span><span style="color: #0000bb;">ending in </span><span style="color: #007700;">{</span><span style="color: #0000bb;">$client_cc_number</span><span style="color: #007700;">}. </span><span style="color: #0000bb;">To update </span><span style="color: #007700;">or </span><span style="color: #0000bb;">change the credit card details we hold </span><span style="color: #007700;">for </span><span style="color: #0000bb;">your account please login at </span><span style="color: #007700;">{</span><span style="color: #0000bb;">$invoice_link</span><span style="color: #007700;">} and </span><span style="color: #0000bb;">click Pay Now then following the instructions on screen.</span></span><span style="font-family: Courier New;"><span style="color: #007700;"><br /></span> </span>" - Unexpected "<" I don't know how to fix this as I do not see the error, thanks everyone for your help Link to comment Share on other sites More sharing options...
sentq Posted October 10, 2015 Share Posted October 10, 2015 the error is this : {</span><span style="color: #0000bb;">$client_name</span></span><span style="font-family: Courier New;"><span style="color: #007700;">}, need to look like this : </span><span style="color: #0000bb;">{$client_name}</span></span><span style="font-family: Courier New;"><span style="color: #007700;">, i think you have added styles to the $client_name and other variables without highlighting the {} holding them, you need to fix that for all variables available in this email template Link to comment Share on other sites More sharing options...
brian! Posted October 10, 2015 Share Posted October 10, 2015 I think the {} are already there, it's all those spans and fonts that are throwing the formatting off... if it were me, i'd clean up the code and paste it directly into the database table - bypassing the form. Link to comment Share on other sites More sharing options...
sentq Posted October 10, 2015 Share Posted October 10, 2015 I think the {} are already there, it's all those spans and fonts that are throwing the formatting off... if it were me, i'd clean up the code and paste it directly into the database table - bypassing the form. read my reply again i think he applied the styles to the $variables it self without highlighting brackets, solution is to highlight the whole text and click "Remove Format" icon/button in editor. Link to comment Share on other sites More sharing options...
brian! Posted October 10, 2015 Share Posted October 10, 2015 read my reply again i think he applied the styles to the $variables it self without highlighting brackets, solution is to highlight the whole text and click "Remove Format" icon/button in editor. fair enough - sounds like good advice! Link to comment Share on other sites More sharing options...
yggdrasil Posted November 20, 2017 Share Posted November 20, 2017 Is this still valid? I would also like to display the date to the correct days before the due date. Link to comment Share on other sites More sharing options...
brian! Posted November 21, 2017 Share Posted November 21, 2017 30 minutes ago, yggdrasil said: Is this still valid? I would also like to display the date to the correct days before the due date. and you can't add the code into the template and test it yourself ? there would be other ways to do it in Smarty, but the only issue I can see with the above method, is that you might have to update your Smarty Security Policy if this is a recent version of WHMCS. Link to comment Share on other sites More sharing options...
Recommended Posts