WHMCS Development

Custom WHMCS Client Area Theme and Order Form Development

By Nikhil Bhangale··6 min read

A developer case study on building an upgrade-safe WHMCS child theme and mobile-friendly order form using theme.yaml inheritance, Smarty templates, and ClientAreaPage action hooks.

Custom WHMCS Client Area Theme and Order Form Development

Earlier this year, a growing hosting provider asked me to audit why paid search traffic on their VPS and cloud hosting landing pages was stalling inside checkout. Their main marketing site felt fast and cohesive, yet the moment a buyer clicked Order Now and crossed over to billing.example.com/cart.php, mobile drop-offs spiked above 60%. On a phone screen, the default WHMCS order flow stacked cramped domain tables, hid multi-year billing discounts inside a reload-heavy dropdown, and looked nothing like the brand the visitor had just trusted. Even worse, a previous developer had edited templates/twenty-one/ directly on the server, leaving the team afraid to apply WHMCS security updates for fear of overwriting their portal.

Working as an independent developer, I re-architected their entire WHMCS frontend into a clean, upgrade-safe child client-area theme paired with a custom order form. Here is how to customize WHMCS deeply for conversions and brand consistency without breaking core billing logic or future platform updates.

Why Stock WHMCS Templates Bleed Mobile Conversions

WHMCS is rock-solid at recurring billing, provisioning modules (cPanel, Proxmox, SolusVM), tax rules, and support ticketing, yet its out-of-the-box templates have three recurring UX bottlenecks for modern hosting brands:

  1. Visual disconnect at the trust boundary: Sending prospects from a polished custom website (such as the setups I discussed in headless WordPress for business websites) onto a generic Bootstrap billing screen creates hesitation right before payment entry.
  2. Opaque billing-cycle selection: Buyers comparing monthly, annual, and triennial plans want to see effective monthly rates and renewal terms immediately without triggering full-page or slow AJAX dropdown refreshes.
  3. Desktop-centric domain and cart steps: Default radio tables in configuredomains.tpl and sidebar summaries in viewcart.tpl squeeze tap targets below usability thresholds on 360px to 390px mobile viewports.

1. Building an Upgrade-Safe Child Theme (theme.yaml)

Editing templates/twenty-one/ or templates/orderforms/standard_cart/ directly is the single most expensive mistake in WHMCS development. Every WHMCS maintenance patch ships updated Smarty templates; if your custom markup lives inside core directories, every security upgrade turns into a painful manual three-way diff.

Modern WHMCS (8.x+) supports native template inheritance through theme.yaml. By declaring twenty-one (and standard_cart for the order form) as the parent, WHMCS loads your custom .tpl overrides where present and falls back cleanly to upstream files everywhere else:

yaml
# templates/hostbrand/theme.yaml
name: "HostBrand Client Area"
description: "Upgrade-safe WHMCS child theme inheriting Twenty-One"
author: "Nikhil Bhangale"
parent: "twenty-one"
config:
  provides:
    bootstrap: "4.6.2"
    jquery: "1.12.4"
    fontawesome: "5.15.4"
properties:
  serverSidePagination: true

Instead of committing 120 copied core templates into Git, our child theme repository contained just 14 deliberate overrides (includes/head.tpl, includes/navbar.tpl, clientareahome.tpl, clientareaproducts.tpl, clientareadetails.tpl, and targeted hostbrand_cart checkout views). When an upstream WHMCS security release drops, core updates apply in minutes with zero lost branding.

2. Replacing {php} Tags with ClientAreaPage Action Hooks

In older WHMCS eras, template authors frequently embedded raw SQL queries or API calls inside Smarty {php} tags. Modern WHMCS and Smarty disable {php} blocks entirely for good reason: mixing executable PHP into presentation templates opens severe server-side template injection risks and turns upgrades brittle.

To power our redesigned client dashboard header (displaying live active service counts, unpaid invoice totals, and open ticket indicators without extra clicks), I moved all data retrieval into a typed action hook at includes/hooks/hostbrand_client_context.php using WHMCS's bundled Illuminate Capsule query builder:

php
<?php
declare(strict_types=1);

use WHMCS\Database\Capsule;

if (!defined('WHMCS')) {
    die('This file cannot be accessed directly');
}

add_hook('ClientAreaPage', 1, function (array $vars): array {
    if (empty($_SESSION['uid'])) {
        return [];
    }

    $clientId = (int) $_SESSION['uid'];

    $activeServices = Capsule::table('tblhosting')
        ->where('userid', $clientId)
        ->where('domainstatus', 'Active')
        ->count();

    $unpaidSummary = Capsule::table('tblinvoices')
        ->where('userid', $clientId)
        ->where('status', 'Unpaid')
        ->selectRaw('COUNT(*) as total_count, COALESCE(SUM(total), 0) as total_due')
        ->first();

    return [
        'hbActiveServicesCount' => $activeServices,
        'hbUnpaidInvoiceCount'  => (int) ($unpaidSummary->total_count ?? 0),
        'hbUnpaidAmountRaw'     => (float) ($unpaidSummary->total_due ?? 0.0),
    ];
});

Respecting WHMCS's native hook lifecycle and cart session state also guaranteed seamless compatibility with third-party and custom payment modules, including the regional checkout flows I built for PayU and MamoPay WHMCS payment gateways.

3. Streamlining Billing Cycles and Domain Steps in Smarty

Inside templates/orderforms/hostbrand_cart/, we redesigned plan comparison, configureproduct.tpl, configuredomains.tpl, and viewcart.tpl around mobile ergonomics while keeping every hidden WHMCS form input, CSRF token ({$token}), and JavaScript cart handler (recalctotals()) intact:

  • Visual billing-cycle cards: Replaced the stock cycle <select> element with touch-friendly radio cards displaying effective monthly cost, upfront billing total, and percentage savings side by side.
  • Segmented domain selector: Consolidated domain registration, transfer, and "use my existing domain and update nameservers" into a clean three-tab segmented control with 48px minimum tap height and instant inline TLD availability feedback.
  • Pinned mobile checkout summary: Below 992px viewport width, a compact sticky footer bar keeps the live order total, promo-code badge, and primary Checkout button reachable with one thumb.
smarty
{* templates/orderforms/hostbrand_cart/partials/billing-cycle-cards.tpl *}
<div class="hb-cycle-grid" role="radiogroup" aria-label="{$LANG.orderbillingcycle|escape}">
  {foreach $pricing.cycles as $cycleKey => $cycleMeta}
    <label class="hb-cycle-card {if $billingcycle eq $cycleKey}is-active{/if}">
      <input
        type="radio"
        name="billingcycle"
        value="{$cycleKey|escape}"
        {if $billingcycle eq $cycleKey}checked{/if}
        onchange="recalctotals();"
      />
      <span class="hb-cycle-name">{$cycleMeta.label|escape}</span>
      <span class="hb-cycle-rate">{$cycleMeta.monthlyEquivalent|escape}<small>/mo</small></span>
      {if $cycleMeta.savingsPercent > 0}
        <span class="hb-cycle-save">Save {$cycleMeta.savingsPercent|intval}%</span>
      {/if}
    </label>
  {/foreach}
</div>

Every output variable passes through Smarty's |escape or |intval modifier to prevent reflected XSS on user-supplied domain or account fields, while onchange="recalctotals();" lets WHMCS recalculate configurable server options (extra IPv4 addresses, automated backups, LiteSpeed licenses) and VAT/GST taxes natively.

4. Scoped CSS Tokens and Frontend Asset Discipline

Rather than fighting Bootstrap specificity with fragile !important overrides across theme.min.css, we namespaced every custom component under .hb-* and defined brand colors, card surfaces, and spacing scales as CSS custom properties inside templates/hostbrand/css/custom.css. Preloading a single variable woff2 webfont, compressing SVG product icons, and deferring non-essential chat widgets until after DOMContentLoaded kept Cumulative Layout Shift (CLS) near zero on cart.php.

Engineering AreaDirect Core Template EditsChild Theme + Hook Architecture
WHMCS Security UpgradesBreaks or overwrites custom UI on updateUpgrade-safe inheritance from twenty-one
Custom Account DataDeprecated/unsafe Smarty {php} blocksTyped ClientAreaPage hooks with Capsule
Mobile Order FlowDropdown reloads and cramped radio tables48px cycle cards, segmented domain tabs, sticky CTA
Cart & Gateway IntegrityProne to broken CSRF tokens or tax mathNative recalctotals(), promo, and gateway support
Git Maintenance Scope100+ mixed vendor files in version control~15 clean .tpl, CSS, and hook files

Project Outcome and Takeaways

Shipping the custom child theme and order form turned the transition between the marketing frontend and WHMCS into one cohesive brand experience, eliminated mobile horizontal scroll and mis-taps during domain configuration, and unblocked the sysadmin team to apply current WHMCS point releases the same week we launched.

  • Project Role: Independent WHMCS & Full-Stack Developer
  • Deliverables: Upgrade-safe WHMCS child client-area theme, custom standard_cart child order form, and ClientAreaPage Capsule data hooks
  • Technologies: WHMCS 8.x, PHP 8.3, Smarty, Illuminate Database Capsule, HTML5, scoped CSS3 custom properties, responsive JavaScript
#WHMCS#client-area#order-form#Smarty#PHP#responsive-design
← Back to all posts

Related Articles

Browse all articles →
WHMCS Development8 min read

Custom WHMCS Payment Gateway Modules: PayU and MamoPay Integration

How I architected custom PayU and MamoPay payment gateway modules for WHMCS in PHP, covering hosted checkout signing, constant-time HMAC webhook validation, idempotency, and currency reconciliation.

Read article →
Daily Work Log13 min read

SolusVM 2 Migration Guide: Fix Agents, License & WHMCS

Today's hands-on work log: migrating a live SolusVM 2 Management Server to a new VPS without touching running Compute Resource VMs, fixing the license IP lock, debugging RabbitMQ and solus-agent start/stop/create failures, and restoring WHMCS automation.

Read article →
Security11 min read

PHP Nov 2026 Critical RCEs: Patch 8.5.13 & 8.4.28 Now

The PHP Foundation released 8.5.13, 8.4.28, 8.3.37, and 8.2.36 on November 19, 2026 fixing 18 security flaws including CVSS 9.2 PHP-FPM smuggling and session upload RCEs. Here is my Linux sysadmin audit, hot mitigation, and multi-PHP patch playbook.

Read article →
Chat on WhatsApp