minadreapta Posted January 4, 2022 Share Posted January 4, 2022 Hello, i have this problem which i think appeared after the upgrade from WHMCS v7 to v8: i have a hook at /includes/hooks/invoice_date.php that modifies the final invoice date to be the actual time of marking the invoice paid, instead of the proforma generation date: <?php function proformainvoicepaiddate($vars) { $invoiceid=$vars["invoiceid"]; update_query("tblinvoices",array("date"=>"now()"),array("id"=>$invoiceid)); } add_hook("InvoicePaid",0,"proformainvoicepaiddate",""); ?> The hook works but it's getting triggered after the PDF invoice email is sent to the client. So the WHMCS sends the email to the client, then the hook runs. The client gets the invoice with the wrong date (the proforma first generation date) and only after this, the hook changes the date on the final invoice. This way in WHMCS i get one date for the final invoice and the client receives an email with a different date for the same invoice. This is illegal in my country. Can you please help me find a workaround for this, i mean getting the hook triggered before the email is sent to the customer? I know now there is a hook-point called EmailPreSend that runs prior to any templated email being sent but i don't know how to implement it, i am not a PHP programmer.https://developers.whmcs.com/hooks-reference/everything-else/#emailpresend Any help here, please? Thanks. 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted January 5, 2022 Share Posted January 5, 2022 Hello bro, You can try using this hook here: https://developers.whmcs.com/hooks-reference/invoices-and-quotes/#invoicepaidpreemail It will trigger once the Invoice is marked as Paid and before the email send. Try this one: <?php function proformainvoicepaiddate($vars) { $invoiceid = $vars["invoiceid"]; update_query("tblinvoices", array("date" => "now()"), array("id" => $invoiceid)); } add_hook("InvoicePaidPreEmail", 0, "proformainvoicepaiddate",""); ?> 0 Quote Link to comment Share on other sites More sharing options...
minadreapta Posted January 9, 2022 Author Share Posted January 9, 2022 On 1/5/2022 at 1:49 PM, andrezzz said: Hello bro, You can try using this hook here: https://developers.whmcs.com/hooks-reference/invoices-and-quotes/#invoicepaidpreemail It will trigger once the Invoice is marked as Paid and before the email send. Try this one: <?php function proformainvoicepaiddate($vars) { $invoiceid = $vars["invoiceid"]; update_query("tblinvoices", array("date" => "now()"), array("id" => $invoiceid)); } add_hook("InvoicePaidPreEmail", 0, "proformainvoicepaiddate",""); ?> That worked. Thanks Andrezzz! 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.