Fringe Posted December 30, 2020 Share Posted December 30, 2020 Hey all, I'm not sure I've posted in the correct section. I'm looking for a way to add some text to every invoice under the invoice number so every customer can read it before paying. I'm just wanting to add the text: "We complete a new anti-fraud check before processing any payments, this may delay your invoice been marked as Paid." as I have some customers who think the payment hasn't actioned so pay again, lol. If it can be added to the top of the invoice but below my company logo/Pay Now button that would be great. I'm not brilliant at code but I can follow instructions if someone is kind enough to answer my question. Cheers 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted December 30, 2020 Share Posted December 30, 2020 Are you wanting to change the PDF or the invoice view within the client area? Editing the templates or using ClientAreaPageViewInvoice and overwriting the pagetitle variable for example would work for the client area view. For the PDF, I believe that might require editing the invoicepdf.tpl template it self. 0 Quote Link to comment Share on other sites More sharing options...
Fringe Posted December 30, 2020 Author Share Posted December 30, 2020 (edited) Hi I want to change the invoice the customer see's in order to pay for the product when they sign up and place the order. The system automattically sends them to the invoice for them to pay so it will be the invoicepdf.tpl template that I will need to edit, I'm just not sure where in the tpl file I need to add the text I want Edited December 30, 2020 by Fringe 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 31, 2020 Share Posted December 31, 2020 15 hours ago, Fringe said: I want to change the invoice the customer see's in order to pay for the product when they sign up and place the order. The system automatically sends them to the invoice for them to pay so it will be the invoicepdf.tpl template that I will need to edit, I'm just not sure where in the tpl file I need to add the text I want I think you're talking about the HTML invoice rather than the PDF version - not least because the PDF version wouldn't necessarily show a Pay Now button, whereas the HTML one would. if you take Steven's suggestion of modifying $pagetitle using a hook (though i'm appending it rather than replacing), then the output would be this... <?php add_hook('ClientAreaPageViewInvoice', 1, function($vars) { if ($vars['status'] != "Paid") { $pagetitle = $vars['pagetitle']; $pagetitle .= '<br><p style="font-size: 11px !important;">We complete a new anti-fraud check before processing any payments, this may delay your invoice being marked as Paid.</p>'; return array("pagetitle" => $pagetitle); } }); 0 Quote Link to comment Share on other sites More sharing options...
Fringe Posted December 31, 2020 Author Share Posted December 31, 2020 (edited) Yes brian! what you just put, thats exactly what I am looking to do, thank you. So if I don't need to edit the invoicepdf.tpl then what file do I need to edit? I use the default invoice from whmcs so where is the file I need to edit located please? I'm using WHMCS v8.0.4 as well Edited December 31, 2020 by Fringe 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 31, 2020 Share Posted December 31, 2020 2 minutes ago, Fringe said: So if I don't need to edit the invoicepdf.tpl then what file do I need to edit? the only reason to edit the PDF invoice template would be if you needed to display this message on the PDF version too.... if that were the case, as Steven says, then you would have to edit the invoicepdf.tpl template. 3 minutes ago, Fringe said: I use the default invoice from whmcs so where is the file I need to edit located please? if you were using the above hook code, you wouldn't need to edit any template - instead, you would create a .php file in /includes/hooks/ (that's the includes folder in your WHMCS folder and not the one in your active template folder), give it a filename, e.g invoicetext.php and paste the above code into it.... then when you next view the invoice, and assuming it's not a paid invoice, the text should be automatically added to the output. 0 Quote Link to comment Share on other sites More sharing options...
Fringe Posted December 31, 2020 Author Share Posted December 31, 2020 Hi brian! I created the php file as suggested, uploaded it and checked and its worked just great, thank you... Just one question? How do I edit it so it runs the full lengh of the invoice? is that possible, the location under the invoice number and Pay Now button is exactly where I wanted it. If I wanted to add this to the pdf invoice as well, is that too complicated or something I could do myself? just asking 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 31, 2020 Share Posted December 31, 2020 5 minutes ago, Fringe said: How do I edit it so it runs the full length of the invoice? is that possible, the location under the invoice number and Pay Now button is exactly where I wanted it. you mean that you want this? with the above hook, I think that would be difficult - you probably can't tell, but the above is a 2 column 50/50 div, and the hook is modifying the content of the left-hand div and that's why the content only fills the left hand side. I think to get a hook to do the above would be to use JavaScript and try to inject the div content where you want it to be - but that can be tricky on the invoice page. FWIW - I did the above screenshot by disabling the hook, editing the viewinvoice.tpl template and adding the div to the code... <div class="col-12 text-center" style="font-size: 11px !important;">We complete a new anti-fraud check before processing any payments, this may delay your invoice being marked as Paid.</div> 0 Quote Link to comment Share on other sites More sharing options...
Fringe Posted December 31, 2020 Author Share Posted December 31, 2020 Hiya I think I will do as you did and edit the viewinvoice.tpl like you have, that would be easier by the sounds of it, lol. Thank you for the help brian! you have been really great and thank you to steven99 for posting a reply, very kind of you. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted December 31, 2020 Share Posted December 31, 2020 Another option might be injecting in to the paymentbutton variable so it shows directly under the payment button. Also tossing on alert styling so it would be an attention grabber would help I'd imagine. <?php add_hook('ClientAreaPageViewInvoice', 1, function($vars) { if ($vars['status'] != "Paid") { $paymentbutton = $vars['paymentbutton']; $paymentbutton .= '<br><p class="alert alert-info">We complete a new anti-fraud check before processing any payments, this may delay your invoice being marked as Paid.</p>'; return array("paymentbutton" => $paymentbutton); } }); 0 Quote Link to comment Share on other sites More sharing options...
Fringe Posted December 31, 2020 Author Share Posted December 31, 2020 Thanks steven99, I will play around with both options to see which fits the best Happy New Year to you both 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 1, 2021 Share Posted January 1, 2021 18 hours ago, Fringe said: If I wanted to add this to the pdf invoice as well, is that too complicated or something I could do myself? just asking you could do it yourself... if ($status != 'Paid') { $pdf->MultiCell(0, 6, 'We complete a new anti-fraud check before processing any payments, this may delay your invoice being marked as Paid.', 0, 'C', false, 1); } in the above example, the code is placed before the # Header Bar code, but you can experiment in the template where you want to add the text - also, you have the option of creating Language Overrides for this text so that it will be shown in the client's own language rather than in the same language for everyone. 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.