WHMCS V 8.10 sell service with a customer existing Subdomain

 

WHMCS is a website software package that sells IT services.

https://www.whmcs.com

We use this software to support our online and hosting service in China.

https://webtest.accesstochina.com

From time to time, we find we need to add features to the WHMCS software to enable us to sell services or information not currently supported by the WHMCS " out-of-the-box” software.

The good news is that WHMCS has many development tools to support making changes as required.

Below are my notes on how to allow services to be sold with a customer's existing subdomain.

I assume you understand the WHMCS development manual, PHP, PHP templates (TPL) and WHCS hooks.

Background

When selling a service, you often add a domain name; e.g., cloud VPS service typically requires a domain/subdomain to locate the service. Example of a domain sold with a service;

 whmcs example1 800

 

WHMCS supports the following domain sources;

    • New domain purchased from ISP with WHMCS have many integrated suppliers
    • Domain you have already purchased
    • Domain transferred into your ISP domain supplier account
    • Customers own domain
    • Subdomain to one existing domain, e.g., customer-sub-domain.b2b66.icu (b2b66.icu is a domain own my business). It is not a subdomain owned by the customer's domain.

 

WHMCS currently does not support customers using their subdomain.

Changes needed WHMCS

Four files need creating/changing.

    • Based on using WHMCS standard template:
      • twenty-one -> orderform -> configureproductdomain.tpl
    • javascript
      • twenty-one -> orderform -> standard_cart -> js -> scripts.min.js
    • Two new hooks
      • ShoppingCartValidateDomain
      • ShoppingCartViewCartOutput

Recommended steps

Please note that these are the steps I took to make changes. I am publishing them as a guide, and they should be tested in a backup development system. Each install of WHMCS can be different based on the version and modules installed.  

If you do not have development services, I recommend not installing these changes in your production system. You can request a development license key from WHMCS, create a copy of your production system, and check they work in your service environment.

1. Create a complete backup of your WHMCS system

2. Make a copy of the twenty-one orderform start_cart directory

    • templates/orderforms/standart_cart -> templates/orderforms/standard_cart2
    • In WHMCS system setting -> general settings -> ordering (tab) select new template name (in this case, standard_cart2). In doing this, you can return to the original template if needed)

3. Create a new field in the template configureproductdomain.tpl for the subdomain;

whmcs example2 800

 

    • Search the template for “{if $owndomainenabled}”. This will give the section of coding needing a change.
    • Add a new input field for the subdomain. Do not call the field “subdomain”. WHMCS already uses this name. I used “subd” and “owndomainsubd”;

                <div>

  <input type="text" id="owndomainsubd" value="{$subd}" placeholder="Subdomain" class="form-control" autocapitalize="none" data-toggle="tooltip" data-placement="top" data-trigger="manual" title="Subdomain" />

</div>

<input type="text" id="owndomainsld" value="{$sld}" placeholder="Domain" class="form-control" autocapitalize="none" data-toggle="tooltip" data-placement="top" data-trigger="manual" title="{lang key='orderForm.enterDomain'}" />

 

    • Review and adjust as required and update the CSS if needed

4. Update the scripts.min.js to make the new data available to Hook

    • We recommend that you reformat the scripts.min.js file into a readable format. I copied the JS code into the JavaScript Beautifier. There are many tools on the Internet for reformatting coding.
    • In the routine, add line “subd”

 jQuery(".domain-selection-options .option").removeClass("option-selected"), jQuery(this).parents(".option").addClass("option-selected"), jQuery(".domain-input-group").hide(), jQuery("#domain" + jQuery(this).val()).show()

    }), jQuery("#frmProductDomain").submit(function(e)  e.preventDefault();

        var t = jQuery(this).find('button[type="submit"]'),

          e = jQuery("#DomainSearchResults"),

            n = jQuery("#spotlightTlds"),

            o = jQuery("#domainSuggestions"),

            f = jQuery("#btnDomainContinue"),

            i = jQuery(".domain-selection-options input:checked").val(),

            a = jQuery("#" + i + "sld"),

            r = a.val(),

            s = "",

            subd = jQuery("#owndomainsubd").val(),

            d = jQuery("#frmProductDomainPid").val(),

            l = "",

            m = jQuery("#idnLanguageSelector");

    • Second change to the JS, again adding “subd”;

 jQuery(".domain-selection-options .option").removeClass("option-selected"), jQuery(this).parents(".option").addClass("option-selected"), jQuery(".domain-input-group").hide(), jQuery("#domain" + jQuery(this).val()).show()

    }), jQuery("#frmProductDomain").submit(function(e) {

        e.preventDefault();

        var t = jQuery(this).find('button[type="submit"]'),

            e = jQuery("#DomainSearchResults"),

            n = jQuery("#spotlightTlds"),

            o = jQuery("#domainSuggestions"),

            f = jQuery("#btnDomainContinue"),

            i = jQuery(".domain-selection-options input:checked").val(),

            a = jQuery("#" + i + "sld"),

            r = a.val(),

            s = "",

        subd = jQuery("#owndomainsubd").val(),

            d = jQuery("#frmProductDomainPid").val(),

            l = "",

            m = jQuery("#idnLanguageSelector");

    • Save the JS file and check that the template is still functioning as before. The subdomain will not be processed until the hooks are created. It is good to check that the changes have not added new bugs to the system.

5. Create ShoppingCartValidateDomain hook

    • Create a PHP file in /includes/hooks/ directory e.g. subdomainvalidate.php

<?php

add_hook('ShoppingCartValidateDomain', 1, function($vars) {    

/// Clear session values

                $_SESSION['subd'] = '';

                $_SESSION['newdomain'] = '';    

//            logActivity('POST Data: ' . var_export($_POST, true));

               

/// set domain  

                $newdomain = isset($_POST['domain']) ? $_POST['domain'] : '';

                logActivity('ShoppingCartValidateDomain - New Domain: ' . $newdomain);

                $_SESSION['newdomain'] = $newdomain;           

/// set subdomain          

                $subd = isset($_POST['subd']) ? $_POST['subd'] : '';

//            logActivity('ShoppingCartValidateDomain - Subdomain: ' . $subd);

                $_SESSION['subd'] = $subd;        

//            logActivity('Session Data: ' . print_r($_SESSION, true), 0);                              

});

    • The hook is only performed when validating a domain name.
    • This script collects the data from the template and creates session values for the next hook.
    • The logActivity is helpful if you need to debug.

6. Create ShoppingCartViewCartOutput hook

    • Create a PHP file in /includes/hooks/ directory e.g. viewcartoutput.php

<?php

if (isset($_SESSION['cart']['products']) && isset($_SESSION['subd']) && !empty($_SESSION['subd'])) {

                foreach ($_SESSION['cart']['products'] as $key => $product) {

                               if (isset($product['domain']) && $product['domain'] === $_SESSION['newdomain']) {

               $_SESSION['cart']['products'][$key]['domain'] = $_SESSION['subd'] . '.' . $product['domain'];

               } } }         });

    • The hook will perform each time the cart is open
    • It will add the subdomain name to the correct domain name and not all domain names in the cart.
    • Below is an example of the output

whmcs exampe3 800

 

Last modified: Version 1.1 - 25 January 2025

 

Useful links for working with China

A curated list of official and practical resources for internet, business, compliance, and trading with China.

Use these links to verify requirements, understand platforms, and plan your next steps.


Focus: official resources + planning Audience: overseas businesses Updated regularly

How to use this page

These links are grouped by common tasks. Where possible, we prioritise official sources and widely-used industry references.

If you are working on a time-sensitive issue (licensing, banking, tax, or compliance), always confirm requirements with a qualified local adviser.

Practical takeaway: Use this page for quick navigation — then confirm the latest requirements with the official source or your adviser.

China internet and ICP filing

Practical takeaway: If you host a public website or service on a China IP address, plan for ICP requirements early.

Chinese search engines and webmaster resources

Practical takeaway: For China SEO, always use the local webmaster platforms (indexing, verification, and guidelines).

Payments and e-commerce platforms

Practical takeaway: Start by understanding platform fees, deposits, logistics and returns — costs can change your margin.

Chinese social media platforms

  • WeChat (Weixin) — messaging, Official Accounts, Mini Programs.
  • Weibo — public social media and brand visibility.
  • Xiaohongshu (RED) — lifestyle, reviews, and social commerce.
  • Douyin — short video and live commerce.
  • Bilibili — video communities and youth culture.
Practical takeaway: Social platforms drive discovery first — sales come later through trust and repetition.

Chinese e-Commerce platforms

  • Tmall — brand-led B2C marketplace.
  • Taobao — C2C and social commerce.
  • JD.com — logistics-driven B2C platform.
  • Pinduoduo — price-driven, group-buying commerce.
  • 1688 — domestic B2B sourcing marketplace.
Practical takeaway: Each platform serves a different buyer type — choosing the wrong one is expensive.

Trade bodies and organisations

Practical takeaway: Trade bodies help with introductions, validation, and policy context — not instant deals.

Business verification and company lookup

Practical takeaway: Always validate who you are talking to, company status, and related entities before committing time or money.

Shipping and customs

Practical takeaway: For consumer shipments, plan duties/taxes and returns before you scale volume.

Helpful tools from Access to China

Practical takeaway: When a page is slow in China, the first step is always to identify blocked resources and routing/hosting constraints.
Useful links for China business

 

Quick checklist

Use these steps when you are researching or validating something in China.

  • Start with official sources (MIIT, CNNIC, Customs, GSXT).
  • Cross-check company registrations before sharing sensitive information.
  • Check whether services you rely on are blocked/slow in China (CDNs, fonts, analytics, maps).
  • Validate platform fees, deposits, and logistics rules before you commit.
  • Keep screenshots and notes — you’ll need them when comparing options.
Note: Requirements and URLs can change. If something looks different, treat it as a sign to re-check the official source.

Need help?

If you’d like help with China website performance, hosting, SEO, or platform strategy, contact This email address is being protected from spambots. You need JavaScript enabled to view it.

Chinese New Year (Spring Festival)

Dates, business impact, and practical planning for overseas companies working with China.

Chinese New Year is the biggest annual shutdown period for factories, logistics, and many business teams in China.


Also called: Spring Festival Typical disruption: 2–4 weeks Last modified: v1.0 – 04 February 2026

What is Chinese New Year?

Chinese New Year (also called the Spring Festival) marks the start of the new year in the Chinese lunisolar calendar. It is a family-focused national holiday and the largest annual migration period in China.

For business, the main issue is operational disruption: factories slow down, shipping capacity tightens, and many teams take extended leave.

Practical takeaway: Treat Chinese New Year like a “business season change” — plan stock, production, and approvals well in advance.

Chinese years

Chinese New Year day falls on a different Gregorian date each year.

YearChinese New Year dayChinese year sign
2025 29 January 2026 Snake
2026 17 February 2026 Horse
2027 6 February 2027 Goat
2028 26 January 2028 Monkey
2029 13 February 2029 Chicken
2030 2 February 2030 Dog
2031 23 January 2031 Pig
2032 11 February 2032 Rat
2033 31 January 2033 Horse
2034 19 February 2034 Tigger
2035 08 February 2035 Rabbit
2036 28 January 2036 Dragon
Practical takeaway: Your project timeline should assume reduced output from late January through February in most years.

Business impact: what changes

  • Factories: early cut-offs for production, slower output, quality risk during ramp-down and ramp-up.
  • Logistics: tighter capacity, higher rates, delays at ports and consolidation hubs.
  • Office teams: decision-makers on leave, slower approvals, reduced support response times.
  • Cashflow: suppliers may request earlier deposits; buyers may pause purchasing.

Planning timeline (simple model)

  • 8–10 weeks before: confirm production plan, lock packaging/artwork, approve samples.
  • 6–8 weeks before: book freight options, confirm warehouse space, finalise promotional plans.
  • 4–6 weeks before: place final orders, confirm cut-off dates with suppliers and forwarders.
  • 2–4 weeks before: expect “last shipments” and reduced responsiveness; focus on urgent priorities only.
  • 2–3 weeks after: gradual restart; plan for backlog and slower ramp-up.
Practical takeaway: If it must ship before CNY, assume your “real” cut-off is earlier than your supplier’s stated cut-off.

Opportunities: marketing and relationship building

  • Send New Year greetings to suppliers and partners (respectful, short, and timely).
  • Plan China-facing campaigns that match seasonal behaviour (gifting, family, travel).
  • Update your customer support plan if you sell to China (expected delivery and response times).

China public holiday window

China’s official Spring Festival holiday typically covers around one week, but the real business disruption is longer due to travel and factory re-staffing.

For 2026, China’s official holiday schedule lists Spring Festival leave across mid‑February, but operational impact commonly starts earlier and ends later.

Need help planning your China timeline?

If you want help mapping a realistic schedule for procurement, website readiness, logistics, or platform launches, contact us and we’ll suggest a practical plan.

Contact: This email address is being protected from spambots. You need JavaScript enabled to view it.
Chinese New Year planning

Use this checklist to avoid last-minute disruption.

Quick checklist

Use these checks to keep trust and usability high.

  • Ask each supplier for their real cut-off date (production + freight).
  • Build buffer time for approvals and rework.
  • Move critical shipments earlier than you think you need to.
  • Confirm stock levels for February–March sales and returns.
  • Plan customer messaging about shipping times (especially cross-border).
  • Schedule marketing assets and translations before the slowdown.
Note: “Looking Chinese” is not the goal. Trust comes from consistency, authenticity, and a smooth mobile experience.

Need help?

If you want a China-ready timeline for trading, platforms, or website performance, contact This email address is being protected from spambots. You need JavaScript enabled to view it..

Access to China — Information Hub

Practical guidance for overseas businesses working with China.

Explore the article collections for being seen, being found, and starting to trade in China.


Focus: China internet + trading Audience: overseas businesses Updated regularly

How this hub is organised

The Access to China information library is organised into three practical collections. Each collection reflects how Chinese users, platforms, and regulations actually work.

Start with reliability (being seen), move to discovery (being found), and then build the trading model and operations (start trading).

Practical takeaway: Start with “Being seen”, then “Being found”, and only then focus on trading.

Browse the article collections

Use the tiles below to enter each collection. Each collection contains topic pages and practical checklists.

Being seen on the Chinese internet

Foundation

Website accessibility, hosting, performance, and trust. Can Chinese users actually load your site?

Being found in China

Discovery

Chinese search engines, SEO, content structure, and how discovery works inside Chinese platforms.

Start trading in China

Execution

Business models, ICP licensing, payments, shipping, B2B vs B2C, and practical risk reduction.

Access to China information hub

Most ‘China problems’ are technical and structural, not marketing-related.

Quick guidance

Use these checks to keep trust and usability high.

  • Can your site load fully inside mainland China (no blocked resources)?
  • Are you using third‑party services that are slow or blocked in China?
  • Does your structure work inside WeChat’s in‑app browser?
  • Do you understand ICP and China hosting rules for public sites?
  • Have you chosen the correct trading model (B2B, B2C, e‑Mall, distributor)?
Note: “Looking Chinese” is not the goal. Trust comes from consistency, authenticity, and a smooth mobile experience.

Need help?

If you’d like help improving mobile usability and China accessibility while keeping an authentic overseas brand feel, contact This email address is being protected from spambots. You need JavaScript enabled to view it.

Note: Looking “Chinese” is not the goal. Being reliable, fast, and clear is.

Our customer data protection policy

How Access to China collects, uses, stores, and protects customer data.

This policy is designed for clarity and practicality, aligned with UK data protection expectations.


Audience: customers + partners Scope: enquiries + services Last modified: v1.0 – 04 February 2026

Summary

This policy explains what personal data we may collect, why we collect it, how we protect it, and the choices you have.

We aim to collect the minimum data needed to deliver the service you requested and to run our business securely.

Practical takeaway: If you only want general information, you can contact us without sharing sensitive personal details.

Who we are

Website: accesstochina.com

Organisation: Access to China

Contact: This email address is being protected from spambots. You need JavaScript enabled to view it.

If you contact us through a form, email, or phone, you are sharing information so we can respond and (where requested) provide services.

What data we collect

  • Contact data: name, company name, email address, phone number.
  • Enquiry data: the content of messages you send us, attachments, and any project details you choose to share.
  • Service data: information required to deliver contracted work (for example: website URLs, hosting details, DNS details, platform accounts, and technical requirements).
  • Billing data: invoicing details and payment references (we do not aim to store full payment card details).
  • Website usage data (limited): technical logs that help operate and secure the website (for example: IP address, user agent, pages requested, error logs).
Practical takeaway: Please do not send passwords by email. If credentials are needed, we will agree a safer method.

How we use your data

  • To respond to enquiries and provide requested information.
  • To deliver and support services you have requested or purchased.
  • To manage billing, accounts, and customer support.
  • To maintain website reliability and security (fraud prevention, malware detection, troubleshooting).
  • To improve our documentation and service quality (using aggregated learning, not public disclosure of your details).

Lawful basis

Depending on the context, our lawful basis may include:

  • Contract: where we are providing services you have purchased.
  • Legitimate interests: responding to enquiries, running our business securely, and improving services.
  • Legal obligation: recordkeeping for tax/accounting where required.
  • Consent: where you explicitly opt-in (for example, certain marketing communications).

Data sharing and third parties

We may share data with trusted providers only when needed to deliver services or operate securely. This can include:

  • Hosting / infrastructure providers, DNS providers, and email providers.
  • Payment / invoicing providers for billing administration.
  • Security providers (for example, malware scanning or monitoring tools).

We do not sell customer data.

Practical takeaway: If your work involves China services, we will flag where data may pass through or be processed by China-based providers.

International transfers

Some technical services may process data outside the UK. Where relevant, we aim to minimise personal data in these systems and use appropriate safeguards.

If you are requesting work specifically involving China infrastructure (for example, ICP/hosting/China platforms), some project data may be handled by China-based providers as part of delivering the service.

Retention

We keep customer data only as long as necessary for the purpose it was collected for, including legal and accounting requirements.

  • Enquiries: typically retained for a reasonable period to manage follow-up and continuity.
  • Contracts and invoices: retained to meet accounting and legal obligations.
  • Operational logs: retained for security and troubleshooting for limited periods.

Security

We use practical security controls appropriate to the type of data handled, such as access control, least-privilege administration, backups, and monitoring.

No online system can be guaranteed 100% secure; however, we take security seriously and act promptly on suspected incidents.

Practical takeaway: If you believe your data may have been shared in error, contact us immediately at This email address is being protected from spambots. You need JavaScript enabled to view it..

Your rights

Depending on your location and applicable law, you may have rights including:

  • Access to the personal data we hold about you.
  • Correction of inaccurate data.
  • Deletion of data (where we have no ongoing lawful basis to retain it).
  • Restriction or objection to certain processing.
  • Data portability (in certain circumstances).

Contact and complaints

If you have a question or request about your data, contact: This email address is being protected from spambots. You need JavaScript enabled to view it.

If you are not satisfied with our response, you may have the right to raise a complaint with the relevant supervisory authority (for example, the UK Information Commissioner’s Office).

Customer data protection policy

Use this checklist when sharing information for a project.

Quick checklist

Use these checks to keep trust and usability high.

  • Share only what’s needed to answer your question or deliver the service.
  • Avoid sending passwords by email; agree a safer method if credentials are required.
  • If sharing technical access, use time-limited accounts and least privilege where possible.
  • Let us know if any data is sensitive (personal IDs, bank details, private customer lists).
  • If your project involves China providers, ask us to minimise personal data in transfers.
Note: “Looking Chinese” is not the goal. Trust comes from consistency, authenticity, and a smooth mobile experience.

Need help?

If you have questions about this policy or how your data is handled, contact This email address is being protected from spambots. You need JavaScript enabled to view it..