Believe_ Posted July 29, 2020 Share Posted July 29, 2020 Great @DennisHermannsen There shouldn't be that case you've mentioned at first, since only one Late Fee entry would be there on a invoice. Even if there are multiple items, there should only be one Late Fee line so there is no issues with it. Anyway, I'll test this out with my test cases and let you know the result as soon as possible. Did you also include the email notifications to the administrator users upon these actions? If this even possible to implement? If so, including that would be a good function. Thanks very much for this help, much appreciated 🙂 0 Quote Link to comment Share on other sites More sharing options...
Believe_ Posted August 28, 2020 Share Posted August 28, 2020 @DennisHermannsen I've tested this and put it in production and all works fine until now. Something I missing out is a notification email to administrators, is this something you could implement on this? 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted August 31, 2020 Author Share Posted August 31, 2020 You can just use this: https://developers.whmcs.com/api-reference/sendemail/ Should just be done at the end of each 'if' 0 Quote Link to comment Share on other sites More sharing options...
natanetwork Posted June 5, 2021 Share Posted June 5, 2021 i need hook with api. do u have? 0 Quote Link to comment Share on other sites More sharing options...
Dknowledge Posted January 14, 2022 Share Posted January 14, 2022 can i still use this code? 2022? 0 Quote Link to comment Share on other sites More sharing options...
Troy Posted March 15, 2022 Share Posted March 15, 2022 (edited) On 1/13/2022 at 6:23 PM, arowolodaniel said: can i still use this code? 2022? FWIW, I tested this today on WHMCS 8.4.1 by ordering a product, provisioning it, leaving the invoice open, and then terminating it. It was of course the simplest of invoices with just the product line item on it, but it worked. Edited March 15, 2022 by Troy 0 Quote Link to comment Share on other sites More sharing options...
Troy Posted March 15, 2022 Share Posted March 15, 2022 What if the module encounters a termination failure? Would this be better as an AfterModuleTerminate hook? Even then I'm not sure whether a failure to terminate would prevent the hook from running, but hopefully not? 0 Quote Link to comment Share on other sites More sharing options...
izadi Posted December 29, 2022 Share Posted December 29, 2022 hi , any one can send here the latest Update of this Hook ? Thanks alot . 0 Quote Link to comment Share on other sites More sharing options...
ShahidMalla Posted January 1, 2023 Share Posted January 1, 2023 add_hook('InvoiceCancelled', 1, function($vars) { // Get the ID of the cancelled invoice $invoice_id = $vars['invoiceid']; // Get the details of the cancelled invoice $invoice = localAPI('GetInvoice', array('invoiceid' => $invoice_id), 'admin'); // Get the products associated with the cancelled invoice $products = $invoice['items']['item']; // Loop through each product foreach ($products as $product) { // If the product is terminated, cancel the invoice if ($product['status'] == 'Terminated') { localAPI('CancelInvoice', array('invoiceid' => $invoice_id), 'admin'); } } }); 0 Quote Link to comment Share on other sites More sharing options...
Shadow Sysop Posted March 20, 2023 Share Posted March 20, 2023 This hook still works perfectly per my testing, You are awesome for providing this to us and I'm super grateful. I'm curious about Multiple products from the same invoice. If the invoice contains 5 different products, but only 1 is terminated, it seems to terminate the entire invoice. Is there a way to require the hook to check that ALL the products have been terminated before cancelling? 0 Quote Link to comment Share on other sites More sharing options...
Tengri Posted May 22, 2023 Share Posted May 22, 2023 Hi! Just vote for this: https://requests.whmcs.com/idea/cancel-invoice-on-termination 0 Quote Link to comment Share on other sites More sharing options...
bear Posted May 22, 2023 Share Posted May 22, 2023 1 hour ago, Tengri said: Hi! Just vote for this: https://requests.whmcs.com/idea/cancel-invoice-on-termination "Josh shared this idea 3 years ago" Like most feature requests, they're ignored. Pointless to vote. 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.