nhudson Posted December 4, 2013 Share Posted December 4, 2013 While WHMCS is supposed to automatically cancel addons when a package is terminated/cancelled, it doesn't always, so I wrote a quick hook to check and cancel the ones that get missed. Figured I'd share <?php function hook_cancel_addon_packages($vars) { $query = mysql_query("SELECT tblhosting.id, tblhosting.domainstatus, tblhostingaddons.hostingid, tblhostingaddons.status FROM tblhosting, tblhostingaddons WHERE (tblhosting.domainstatus != 'Active' AND tblhosting.domainstatus != 'Suspended') AND (tblhostingaddons.status = 'Active' OR tblhostingaddons.status = 'Suspended') AND tblhostingaddons.hostingid = tblhosting.id"); while($row=mysql_fetch_array($query)) { $hostingid = $row['hostingid']; $query = mysql_query("UPDATE tblhostingaddons SET status = 'Cancelled' WHERE hostingid = '$hostingid'"); } } add_hook("DailyCronJob",1,"hook_cancel_addon_packages"); ?> 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.