Howtos

WHMCS HowTos

How to do a Free Trial Promotion

Delayed Ordering

  • A hook to ensure the recurring prorata invoice isn’t generated
  • Next due date 0000-00-00 after order
  • When order is made active
    • prorata invoice created
    • examine products to see if prorata is active
      • next due date is synced to end of prorata date

Invoice next due dates

Below describes the WHMCS process when calculating next due dates when not using continuous invoice generation. A link is explored to obtain additional information.

  • The Next Due Date of all Active, Pending and Suspended services are analysed
  • Determine if the date is equal to or less than the number of days in the future specified by the Invoice Generation setting
  • Ensure no invoice item exists for the service on the next due date
  • If the above points are evaluated to be true, then a new invoice is generated.
  • The InvoiceCreation Action Hook point is triggered
  • The InvoiceCreationPreEmail Action Hook point is triggered
  • The Invoice Created email is sent to the client
  • The InvoiceCreated Action Hook point is triggered
  • The Next Invoice Date of the service is incremented forward by one billing cycle.

Reference:

configoptions / AddOrder API

<?php
$postfields["configoptions"] = base64_encode(serialize(
    [
        "78"=>"221",
        "77"=>"219",
        "76"=>"217"
    ])
);

78 - id from the tblproductconfigoptions table

221 is id of the value you need of that option from the tblproductconfigoptionssub table where configid=78..

The 77 and 76 defines similar..

WHMCS Name Spaces

WHMCS has it’s own name spaces. These are mostly documented, but as it’s closed source we cannot deduce relationships and rely on our own models where possible.

Rename Menus

This technique can be used to rename any English language word in WHMCS

cat /lang/english.php

$_LANG['announcementstitle'] = "News";
$_LANG['knowledgebasetitle'] = "FAQs"

Disable Sidebar Menu

Settings / General / Ordering

Tick to enable the display of a sidebar toggle button on Order Form Product Selection Pages

Hide Menus

This comprehensive hooks file shows how to hide most of the ‘extra’ menus WHMCS supplies. It strips it down to a very basic system great for just recurring billing.

cat includes/hooks/example_hook_file.php 

<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");

use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{

    // Anonymous
    
    if (!is_null($primaryNavbar->getChild('Network Status'))) {
        $primaryNavbar->removeChild('Network Status');
    }
    
    if (!is_null($primaryNavbar->getChild('Store'))) {
	$primaryNavbar->getChild('Store')->removeChild('Register a New Domain');
	$primaryNavbar->getChild('Store')->removeChild('Transfer a Domain to Us');
    }
    
    if (!is_null($primaryNavbar->getChild('Support'))) {
	$primaryNavbar->getChild('Support')->removeChild('Downloads');
	$primaryNavbar->getChild('Support')->removeChild('Network Status');
    }
    
    if (!is_null($primaryNavbar->getChild('Services'))) {
	$primaryNavbar->getChild('Services')->removeChild('View Available Addons');
    }
    
    // Logged In
    
    if (!is_null($primaryNavbar->getChild('Domains'))) {
        $primaryNavbar->removeChild('Domains');
    }
        
});

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
    if (!is_null($secondarySidebar->getChild('Client Contacts'))) {
        $secondarySidebar->removeChild('Client Contacts');
    }
    if (!is_null($secondarySidebar->getChild('Client Shortcuts'))) {
	$secondarySidebar->removeChild('Client Shortcuts');
    }
    
    if (!is_null($secondarySidebar->getChild('Actions'))) {
	$secondarySidebar->removeChild('Actions');
    }
    
    if(!is_null($secondarySidebar->getChild('Support')) && !is_null($secondarySidebar->getChild('Support')->getChild('Network Status'))) {
        $secondarySidebar->getChild('Support')->removeChild('Network Status');
    }

    if(!is_null($secondarySidebar->getChild('Support')) && !is_null($secondarySidebar->getChild('Support')->getChild('Downloads'))) {
        $secondarySidebar->getChild('Support')->removeChild('Downloads');
    }
    
    if(!is_null($secondarySidebar->getChild('Categories')) && !is_null($secondarySidebar->getChild('Categories')->getChild('Addons'))) {
        $secondarySidebar->getChild('Categories')->removeChild('Addons');
    }
    
    if (!is_null($secondarySidebar->getChild('Support'))) {
    //	$secondarySidebar->removeChild('Support');
    }
    
});

// Example supplied with WHMCS
function create_forum_account($vars) {
    $firstname = $vars['firstname'];
    $lastname = $vars['lastname'];
    $email = $vars['email'];
    // Run code to create remote forum account here...
}
// add_hook("ClientAdd",1,"create_forum_account");

References