Guide customers to correctly renew fees and control customer misoperations to generate abandoned bills
Work on WHMCS 7.x and 8.X
add_hook('ShoppingCartViewCartOutput',1,function ($vars) { $unpaidinvoices =newWHMCS_ClientArea();if ($unpaidinvoices->isLoggedIn()) { $active_product_no = Capsule::table('tblhosting')->where('userid', $unpaidinvoices->getUserID())->where('domainstatus', 'Active')->count();
$unpaid_invoice_no = Capsule::table('tblinvoices')->where('userid', $unpaidinvoices->getUserID())->where('status', 'Unpaid')->count();
if ($active_product_no >0&& $unpaid_invoice_no >0) { echo '<script>if(confirm("You have ' . $active_product_no . ' effective products and ' . $unpaid_invoice_no . ' pending bills!\nBefore purchasing a new product, you must pay these bills first!\nPlease click confirm to pay the bill!")){location.href=\'clientarea.php?action=invoices\';}else{location.href=\'index.php\';};</script>';
} elseif ($active_product_no >0&& $unpaid_invoice_no ==0) { $return = '<div class="alert alert-warning text-center" role="alert">You have ' . $active_product_no . ' effective products, If you want to renew an existing product, please cancel this purchase, and the system will generate an order and notify you before the existing product expires!</br>If you want to purchase the product again (that is, you own two or more products at the same time), please complete this purchase!</div>';
return $return; } elseif ($active_product_no =0&& $unpaid_invoice_no >0) { echo '<script>if(confirm("You have ' . $unpaid_invoice_no . ' pending bills!\nPlease click Confirm to end this purchase and check & pay the corresponding bill to complete the purchase!\nIf you want to purchase other products (products not corresponding to the generated bill), please click Cancel!")){location.href=\'clientarea.php?action=invoices\';};</script>';
} }});
Automatically cancel overdue orders and bills
Let WHMCS automatically cancel overdue orders and bills
Before using, please set the administrator username in the code and the time of automatic cancellation
Force users to verify their email address, otherwise they will refuse to access the product details page
Work on WHMCS 7.x and 8.X
add_hook('ClientAreaPageProductDetails',1,function($var){ $email_ca =newWHMCS_ClientArea();if ($email_ca->isLoggedIn()) { $adminuser ="NutterChen"; $result =Capsule::table('tblclients')->where('id','=', $email_ca->getUserID())->get()[0]->email_verified;if ($result =="0") { echo '<script>if(confirm("You have not verified your email, access is denied!\nPlease click confirm to back to homepage and verify email!\nPlease click cancel to modify account information!")){location.href=\'clientarea.php\';}else{location.href=\'clientarea.php?action=details\';};</script>';
exit(); } }});
Restrict email suffix
Restrict users' registered email suffixes so that users can only use specific email addresses to register
Please set the available email suffix before use, use commas to separate the email suffix (in the third line of the code)
Work on WHMCS 7.x and 8.X
add_hook('ClientDetailsValidation',1,function($vars) { $EmailAddress =explode('@',trim($vars['email'])); $AllowAddress ='baidu.com,qq.com,ter.com'; $AllowAddressArray = array(); $AllowAddressArray =explode(',',$AllowAddress);if(!@$EmailAddress[1]){return array('Incorrect email'); } else {foreach ($AllowAddressArray as $AllowAddressForeach){if(strpos($EmailAddress[1],$AllowAddressForeach)!==true){return array('Email suffix is not allowed'); } } }});
Prohibit immediate cancellation
Prohibit immediate cancellation through hidden options