Jump to content

Add text to invoice


Fringe

Recommended Posts

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

Link to comment
Share on other sites

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 by Fringe
Link to comment
Share on other sites

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...

Kt1Tnyh.png

<?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);
	}
});
Link to comment
Share on other sites

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 by Fringe
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

eXH1efe.png

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>
Link to comment
Share on other sites

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. 

image.png.305440f626cb2ad4351102893b92b353.png

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

 

Link to comment
Share on other sites

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

YF9cr3G.png

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated