\WHMCS\Database\Capsule::table("tblhosting")
->join("tblclients", "tblhosting.userid", "=", "tblclients.id")
->join("tblproducts", "tblhosting.packageid", "=", "tblproducts.id")
->select("tblclients.email", "tblclients.phonenumber")
->whereIn("tblhosting.domainstatus", ["Cancelled", "Terminated"])
->where("tblhosting.domain", "<>", "")
->whereIn("tblproducts.gid", [1, 2]) # Add product group id here
->get();
SELECT `tblclients`.`email`, `tblclients`.`phonenumber`, `tblproducts`.`name`
FROM `tblhosting`
INNER JOIN `tblclients` ON `tblhosting`.`userid` = `tblclients`.`id`
INNER JOIN `tblproducts` ON `tblhosting`.`packageid` = `tblproducts`.`id`
WHERE `tblhosting`.`domainstatus` ON ("Cancelled", "Terminated")
AND `tblhosting`.`domain` <> ""
AND `tblproducts`.`gid` in (1, 2) # Add product group id here
You can always modify it, as your desire.