Jump to content

Display Hook Function on viewinvoice.tpl


Recommended Posts

Hello,

I have create hook on quotepdf.tpl

this is the code :

 

function landingflash_invoice_hook($vars) {

return array(
'pagetitle' => $vars['pagetitle'] . '<br><div style="font-size:12px;">'
landingflash_generate_code( $vars['invoiceid']).'</div>',
);
}
add_hook(ClientAreaPageViewInvoice", 1, "landinfglash_invoice_hook");

function landingflash_generate_code($invoice){

$secret_key = 'lfgapura';
$secret_iv = '123456';

$encrypt_method = 'AES-256-CBC';
$key = hash('sha256', '$secret_key');
$iv = substr( hash('sha256' , $secret_iv), 8, 16);

return base64_encode( openssl_encrypt($invoice, $encrypt_method, $key, 0, $iv));
}


And then i want to display it under invoice ID on viewInvoice.tpl  and it should displayed like this : http://prntscr.com/138455n

Do you know how to display the function result?

Thank you
 

Link to comment
Share on other sites

On 21/05/2021 at 15:36, Waranugraha said:

Do you know how to display the function result?

you have three issues...

  1. you mention quotepdf.tpl, but I assume you're really talking about invoicepdf.tpl, e.g invoices and not quotes.
  2. you cannot use hooks with either of the pdf templates - you would need to edit the relevant template directly.
  3. if you wanted the hook to work on the HTML invoice, then the following should work...
    <?php
    
    add_hook('ClientAreaPageViewInvoice', 1, function($vars) {
    	
    	$secret_key = 'lfgapura';
    	$secret_iv = '123456';
    	$encrypt_method = 'AES-256-CBC';
    	$key = hash('sha256', $secret_key);
    	$iv = substr( hash('sha256' , $secret_iv), 8, 16);
    	$hash = base64_encode(openssl_encrypt($invoice, $encrypt_method, $key, 0, $iv));
    	$pagetitle = $vars['pagetitle'] . '<br><div style="font-size:12px;">'. $hash . '</div>';
    	return array("pagetitle" => $pagetitle);
    });

    ... but to repeat, no hook would work on the PDF invoices, but you can use PHP when editing those templates.

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