chrigu Posted September 17, 2020 Share Posted September 17, 2020 Hello guys. We are devloping a module, which groups all our invoices each month. When the cronjob creates an invoice, we are going to delete it. For correct the number of created invoices the cronjob sends, we need to decrease. Do you have any idea, how we can do that? Thanks! 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted September 17, 2020 Share Posted September 17, 2020 With SQL in 5 action hooks. It's pretty much complicated as some of these hooks run "in the same time". Some other work conditionally depending on WHMCS configuration. As if it wasn't enough, you have to keep in mind that WHMCS issues invoices in a lot of different ways. Detecting them is crucial otherwise you'll cause billing errors. Lastly some types of invoices can't be deleted and you can't just decrease invoice count by 1. Good luck, you'll need it 🤐 0 Quote Link to comment Share on other sites More sharing options...
Wouter0100 Posted September 17, 2020 Share Posted September 17, 2020 (edited) I would agree with @Kian on this. I've attempted such an addon myself, but have never fiinished it due to the complexity and the nature of some processes in WHMCS. Also seen colleagues create such an addon, but it never really functioned without issues (and there would be a large business for this addon if it would). Besides, if you really do want to alter this number in the cronjob e-mail - you should be able to do so with the `PostAutomationTask`, like so: <?php add_hook('PostAutomationTask', 1, function($vars) { if (!($vars instanceof \WHMCS\Cron\Task\CreateInvoices)) { return; } $vars->output('invoice.created')->write(13); }); In this case 13 is the random number you want to set in the invoice e-mail. I'm not aware of the side effects, so please use with care. Edited September 17, 2020 by Wouter0100 0 Quote Link to comment Share on other sites More sharing options...
chrigu Posted September 18, 2020 Author Share Posted September 18, 2020 12 hours ago, Wouter0100 said: I would agree with @Kian on this. I've attempted such an addon myself, but have never fiinished it due to the complexity and the nature of some processes in WHMCS. Also seen colleagues create such an addon, but it never really functioned without issues (and there would be a large business for this addon if it would). Besides, if you really do want to alter this number in the cronjob e-mail - you should be able to do so with the `PostAutomationTask`, like so: <?php add_hook('PostAutomationTask', 1, function($vars) { if (!($vars instanceof \WHMCS\Cron\Task\CreateInvoices)) { return; } $vars->output('invoice.created')->write(13); }); In this case 13 is the random number you want to set in the invoice e-mail. I'm not aware of the side effects, so please use with care. Thank you, great! We have a lot of different cases and work since month on this plugin. I think we are done so far and we also support some 3rd party plugins. It would be great if you tell me, what your issues was. So maybe we can cross check if we already work with them. It would be great to hear a 2nd workflow. Thank you! 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.