How to add additional text or Bank details on WHMCS View Invoice & PDF Invoice

·

How to add additional text or Bank details on WHMCS View Invoice & PDF Invoice

If you were to use the hook code functionality, 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 someText.php and paste the below code into it…. then when you next view the invoice, and assuming it’s not a paid invoice (you can remove the if condition if this is not required), the text should be automatically added to the output.

<?php

add_hook('ClientAreaPageViewInvoice', 1, function($vars) {
	
	if ($vars['status'] != "Paid") {
		$pagetitle = $vars['pagetitle'];
		$pagetitle .= '<br><p style="font-size: 11px !important;">This is the additional text we want to show under Invoice Numeber</p>';
		return array("pagetitle" => $pagetitle);
	}
});

Also if we wanted to show it as an Alert and also show it along the payment button we can modify it as follows:

<?php

add_hook('ClientAreaPageViewInvoice', 1, function($vars) {

        if ($vars['status'] != "Paid") {
                $paymentbutton = $vars['paymentbutton'];
                $paymentbutton .= '<br><p class="alert alert-info">This is the additional text we want to show under Invoice Numeber</p>';
                return array("paymentbutton" => $paymentbutton);
        }
});

Now, However if you wanted to add this text to the PDF Invoice template also,  then you would have to edit the invoicepdf.tpl template.

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);
}