Creating a Custom Notification of Remaining Credits Print

  • 3

This knowledge base is for WHMCS v5 only.  Please refer to the following GIT repository for the new approach.

You can create a custom experience by adding the following code to any portion of your WHMCS client area template. 
The display will be a box indicating to your cleint that more hours will need to be purchased before they continue receiving premium support.


{if $loggedin}
    $clientId = $this->_tpl_vars['clientsdetails']['id'];
    $dbh =& wbDatabase::getInstance();
      SELECT (SELECT SUM(`log`.`hours`) FROM `tbladdon_wbclientstimelog` AS `log` WHERE `log`.`userid` = '$clientId') AS `total_hours`
        , (SELECT SUM(`credit`.`hours`) FROM `tbladdon_wbclientstimelog_credits` AS `credit` WHERE `credit`.`userid` = '$clientId') AS `total_credits`
    $report = $dbh->getRow();
    $this->_tpl_vars['wbtimelog_report'] = array();
    $this->_tpl_vars['wbtimelog_report']['total_hours'] = round($report['total_hours'],2);
    $this->_tpl_vars['wbtimelog_report']['total_credits'] = round($report['total_credits'],2);
    $report['total_balance'] = $report['total_credits'] - $report['total_hours'];
    $this->_tpl_vars['wbtimelog_report']['total_balance'] = round($report['total_balance'],2);
    $this->_tpl_vars['wbtimelog_report']['total_balance_formatted'] = ($report['total_balance'] >= 0 ? round($report['total_balance'],2) : '<font color=red>('.abs(round($report['total_balance'],2)).')</font>');
  <div class="wbtimelog_widget">
    <p>You have <b>{$wbtimelog_report.total_balance_formatted} hours</b> remaining of premium support.</p>
    <button>Click here to purchase more hours</button>
    .wbtimelog_widget {
      border:1px solid #999;

Was this answer helpful?

« Back