How to Add Payment Details to your WHMCS PDF Invoices
WHMCS provides some documentation on how to customise your PDF Invoices. Their article includes some specific pointers to help you add your own logo, and it gives an overview of the available variables which I found useful… however for the uninitiated or PHP-challenged I can imagine that doing something simple like adding available payment methods to your invoices would remain a mystery. So, here’s a simple tutorial you can follow to add payment details to your WHMCS PDF invoices.
Demo
Click here to see what we’re creating – a nice PDF invoice with details on how to pay in 3 columns across the bottom.
Tutorial
- Locate your active WHMCS template folder. The easiest way to do that is to log in to your WHMCS install and go to Settings > General Settings, and check the name of the folder that appears in the Template drop-down as pictured below:
- Now, in your FTP client find invoicepdf.tpl in your active Template folder. This is the template we’re going to edit to control what appears on your PDF invoices.
- Copy the following code into invoicepdf.tpl before the closing
?>
tag.#Payment Method $pdf->SetFont('freesans','B',12); $pdf->Cell(0,4,"HOW TO PAY",0,1,'C'); $pdf->Ln(5); $pdf->SetFont('freesans','',9); $paymethhtml = '
Cheque
Please send cheque payable to:
Your Company Name
XXX Something St
Suburb XXXXBank Transfer
Account Name: XXXX
BSB: XXXXXX
Account No: XXXXXXXX
Ref: #'.$invoicenum.'Credit Card
Please phone us with your card details to pay with Visa or MastercardYou’ll notice we’re telling it to use freesans font – you can customise or remove that as needed. Remember to substitute in your own postal address and bank account details so your customers can pay you.
- Once you’ve customised the payment details you’re ready to save and upload back to your Template folder via FTP
- Test it… Tweak it. Once you’re happy, you’re done!
Note that this just adds your payments details to the PDF version of invoices. You may also want to add your details to the ‘invoice created’ email that client’s get sent (this can be done via WHMCS Settings > Email Templates) and on the version of the invoice that appears in the client portal area (this can be done in viewinvoice.tpl in the active templates folder).
Full copy of our customised invoicepdf.tpl file here.
Awesome! I searched around for an easy way to add payment details to our invoice pdf template and found this article. I added your code and it works like a charm. Thanks for sharing this custom code and thinking of us PHP challenged whmcs users.
Mick
Wow very Awesome Tutorial!!!
I have applied on my invoice template and successfully
Thanks
Brilliant tutorial. Thanks. May I ask how to put the address of your company like you did on the top right corner as well? Thanks in advance
Glad you found it helpful Chee. The address at the top right is put in automatically by WHMCS. It grabs those details from Settings > General, so check that you’ve entered your address in there and it should add it to the PDF.
Thanks, a great little addition to the PDF Invoice. Much appreciated.
One thing we did was to add ‘Ref:#$invoicenum’ at the end of the electronic transfer code so that it produces the invoice number under the bank details….a little reminder to the client to quote that ref when paying!
We also changed the code slightly as we use the PDF Invoice Auto Login link which was conflicting with the ‘HOW TO PAY’ code. We also don’t accept cheques so we removed that part. Here’s our code:
# Payment Details
$pdf->Ln(8);
$pdf->SetFont(‘freesans’,’B’,12);
$pdf->Cell(28,7,”Ways To Pay”,0,1,’C’);
$pdf->SetFont(‘freesans’,’B’,9);
$pdf->Cell(60,7,”Bank Transfer”,0,0,’L’);$pdf->Cell(60,7,”Credit / Debit Card”,0,0,’L’);
$pdf->Ln(6);
$pdf->SetFont(‘freesans’,”,9);
$ypos = $pdf->GetY();
$pdf->SetXY(15,$ypos);
$pdf->MultiCell(60,4,”Bank: Bank_Name_here\nAcc. Name: Account_Name_here\nSort Code: 12-34-56\nAccount No: 123456789\nRef:#$invoicenum”);
$pdf->SetXY(75,$ypos);
$pdf->MultiCell(60,4,”Please Click ‘Pay Invoice’\nor Login to the Client Area\nto pay by Credit / Debit Card\n”);
Hope that helps someone.
Great Article, thanks so much just what I was looking for.
Hi,
Tried pasting the code to invoicepdf.tpl after
# Generation Date
$pdf->SetFont(‘freesans’,”,8);
$pdf->Ln(5);
$pdf->Cell(180,4,$_LANG[‘invoicepdfgenerated’].’ ‘.getTodaysDate(1),”,”,’C’);
Before ?>
But didnt work whenever I try downloding the pdf there is error for the .tpl file , however I didnt change anything else.
Hi Lily, if you’re getting an error it usually means there are code errors – things like missing closing tags or ;’s. I’d suggest reverting to a backup and then giving this mod another try, making sure to copy everything exactly and checking you haven’t accidentally obscured any other code there. If you continue to have problems feel free to email me privately and I’d be happy to help you out.
Hello,
Just tried this with the current WHMCS version, no luck.
When downloading the invoice, it just hangs. No invoice is produced.
I tried it both with my info, and as-is, as above.
I also checked to make sure there were proper line endings and escapes.
Any info would be appreciated.
Thanks,
-Deano
I figured it out.
It didn’t like some of the code that was being entered, namely the “->” special chars.
I don’t know why they don’t just make the templates simply HTML, it would be so much simpler for everyone, and some really nice looking templates could be made.
Thanks for this code snippet, it is appreciated.
-Deano
Does this still work with the latest whmcs i.e 6.2.2?
I asked this because I could not loacte the closing ?> tag in the invoicepdf.tpl file.
Rgds all,
Banjo
Hi Banjo, yeah it should definitely work. Not sure why the closing ?> tag is missing… that’s very strange for a php file… it would cause a lot of errors…
Hi thanks for the great article
my question is where do i paste the code on my invoicepdf.tpl template
Thanks
Right before the closing ?> tag.
Hi
I too do not have a ?> closing tag in version 6.2.2. As a result I have no idea where to put the code?
Cheers
Theo
Hmm maybe there have been some template changes recently. I’ll check it out. In the meantime try simply adding the code at the bottom of the file.
Thanks for the code it helped heaps.
I have one small issue the header ( Payment Details ) has been pushed to the far right of the Generated Date and all the rest has been bumped to the next page.
Any Ideas what I can do to get it all onto one page? and center the Payment Details header.
I am not a PHP coder.
Thanks
John
Hmm without seeing it it’s hard to advise, but stuff drops to next line or next page when the contents is too long and won’t fit. Shorten the content in some way to fix that. Feel free to get in touch privately via email for more specific help if you need. Always happy to assist where possible.
Great guide, thank you so much Maeve. I think WHMCS must add this to the admin area to make this available to all of the customers. I think that most of the users of WHMCS needs to add payment methonds to the invoice.
Thanks again!
Thanks Santiago, definitely seems essential to me! But I guess maybe some WHMCS users make more heavy use of the online portal for payment processing.
This worked awesome to me. Thanks for the same 🙂
How to insert image in footer of emailed invoices, i used the img tag of HTML and its working while downloading the invoice from unpaid invoices section image is showing on the pdf files of invoices but it’s not showing on emailed pdf invoices.
Thank you so much!