Jump to content

Action Hook - Cancel addons for cancelled packages


nhudson

Recommended Posts

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");
?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated