Waranugraha Posted May 21, 2021 Share Posted May 21, 2021 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 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 24, 2021 Share Posted May 24, 2021 On 21/05/2021 at 15:36, Waranugraha said: Do you know how to display the function result? you have three issues... you mention quotepdf.tpl, but I assume you're really talking about invoicepdf.tpl, e.g invoices and not quotes. you cannot use hooks with either of the pdf templates - you would need to edit the relevant template directly. 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. 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.