Web Host Pro Posted December 27, 2018 Share Posted December 27, 2018 It looks like WHMCS is terminated accounts that are the set past due but it's not removing the invoices. Is there a way for WHMCS to see if the account is terminated or cancelled and remove the invoice if it is? 0 Quote Link to comment Share on other sites More sharing options...
WHMCS ChrisD Posted December 28, 2018 Share Posted December 28, 2018 @Web Host Pro something like https://marketplace.whmcs.com/product/2622 would assist you 0 Quote Link to comment Share on other sites More sharing options...
Web Host Pro Posted January 2, 2019 Author Share Posted January 2, 2019 Wow, interesting thanks. I'll try it. 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted January 2, 2019 Share Posted January 2, 2019 It can also be done using a hook. <?php $daysBeforeCancel = '60'; //Change this to how many days you want to wait for the system to cancel an invoice after the due date use WHMCS\Database\Capsule; add_hook('DailyCronJobPreEmail', 1, function($vars) { $command = 'GetInvoices'; $postData = array( 'status' => 'Overdue', 'limitnum' => '700', ); $results = localAPI($command, $postData); foreach ($results['invoices']['invoice'] as $cancelInvoice){ if(strtotime($cancelInvoice['duedate']) < strtotime($daysBeforeCancel)) { $command = 'UpdateInvoice'; $postData = array( 'invoiceid' => $cancelInvoice['id'], 'status' => 'Cancelled', ); $results = localAPI($command, $postData); }; } }); 0 Quote Link to comment Share on other sites More sharing options...
Andrea D. Posted July 29, 2022 Share Posted July 29, 2022 On 1/3/2019 at 12:02 AM, DennisHermannsen said: It can also be done using a hook. <?php $daysBeforeCancel = '60'; //Change this to how many days you want to wait for the system to cancel an invoice after the due date use WHMCS\Database\Capsule; add_hook('DailyCronJobPreEmail', 1, function($vars) { $command = 'GetInvoices'; $postData = array( 'status' => 'Overdue', 'limitnum' => '700', ); $results = localAPI($command, $postData); foreach ($results['invoices']['invoice'] as $cancelInvoice){ if(strtotime($cancelInvoice['duedate']) < strtotime($daysBeforeCancel)) { $command = 'UpdateInvoice'; $postData = array( 'invoiceid' => $cancelInvoice['id'], 'status' => 'Cancelled', ); $results = localAPI($command, $postData); }; } }); Hello! Thank you for sharing the code but unfortunately it is not working for me. Do you think this code is outdated? 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.