Linking to WHMCS

Linking to WHMCS is one of the first things to do after you set up WHMCS. You can create login or product links for the Client Area, a shortcut to a ticket submission form, or an order form purchase link.

  • For code to add a domain availability check, login form, or domain purchase link to your website, go to Utilities > Integration Code in the Admin Area.
  • You may also want to use data feeds.
The examples below use a WHMCS installation at http://www.example.com/whmcs.

You can use the following URLs to link to WHMCS:

AreaExample LinkDescription
Client Areahttp://www.example.com/whmcs/clientarea.phpA link to the Client Area Homepage, allowing the user to manage their client accounts. If the user has not already authenticated, this link will direct them to a login prompt.
Shopping Carthttp://www.example.com/whmcs/cart.phpA link to the active shopping cart.
Individual Productshttp://www.example.com/whmcs/store/shared-hosting/starterA direct link to a specific product or to load the product into the cart and take the user directly to configure it.
For more information, see Product Links and Constructing Links below.

You can find the links for each product in the Links tab when you edit the product at Configuration () > System Settings > Products/Services:

The Links tab in Products/Services

You can copy the following direct links for the product and its associated group:

URLDescription
Direct Shopping Cart LinkAdd the product to the shopping cart and direct the visitor to the configuration page.
Direct Shopping Cart Link Specifying TemplateAdd the product to the shopping cart and direct the visitor to the configuration page using the specified order form template.
Direct Shopping Cart Link Including DomainAdd the product to the shopping cart and direct the visitor to the domain selection page.
Product Group Cart LinkDirect the visitor to the product group page.
Product URLsDirect the visitor to the Direct Shopping Cart Link URL and track the number of visits for that URL. Each time that a visitor clicks on one of these URLs, the Visits count will increase.
To delete a Product URL, click the corresponding red delete icon.
  • You cannot delete the active URL.
  • After you delete a product URL, the link will become nonfunctional.
The examples below use the Direct Shopping Cart Link URL for a product.

You can append additional variables and values onto links to customize them:

Variable or ValueDescriptionExample Link
billingcycleLink to a preselected product with an annual billing cycle.http://example.com/whmcs/cart.php?a=add&pid=1&billingcycle=annually
sld and tldLink to a preselected product with a selected domain name (sld) and extension (tld).http://example.com/whmcs/cart.php?a=add&pid=1&sld=google&tld=.com
domainoption and sldLink to a preselected product with a subdomain.http://example.com/whmcs/cart.php?a=add&pid=1&domainoption=subdomain&sld=google
promocodeLink to the shopping cart and automatically apply a promotion code.http://example.com/whmcs/cart.php?promocode=xxxxxxx
gidLink to a product group using the product group ID (gid).http://example.com/whmcs/cart.php?gid=1
carttplLink to the shopping cart and specify an order form template to use.http://example.com/whmcs/cart.php?carttpl=boxes
bidLink to a product bundle using the bundle ID (bid).http://example.com/whmcs/cart.php?a=add&bid=X

Configurable Options

You can also create your own configurable options.

To create a configurable option URL:

  1. Step through the order process normally until you reach the product configuration step.
  2. Right click and select View Source.
  3. Retrieve the field names and value IDs. You can use these in your direct link URLs.

For example:

<p class="cartsubheading">Configurable Options</p>
<p>This product or service has some options that you can choose to customise your
order.</p>

<div class="cartbox">
<table cellspacing="0" cellpadding="0">
<tr><td>Disk Space:</td><td width="5"></td><td>
<input type="text" name="configoption[1]" value="100" size="5"> x 1MB $0.00USD
</td></tr>
</table>
</div>

You would then use http://example.com/whmcs/cart.php?a=add&pid=1&configoption[1]=100 as the link URL, setting the value of the first configurable option to 100.

Custom Fields

You can also create your own custom fields using a similar method to creating configurable options.

For example, the following link would prefill the custom field option, the day of the week, with the value Friday:

http://example.com/whmcs/cart.php?a=add&pid=5&cf_dayofweek=Friday

You can skip the configuration page entirely if you have defined all of the configuration values in the URL by adding &skipconfig=1 to your order URL. If there is missing configuration data, this would generate an error and force the client to edit the configuration. For example:

http://example.com/whmcs/cart.php?a=add&pid=5&cf_dayofweek=Friday&skipconfig=1

Custom field names must not contain any special characters other than underscores in order to prefill custom fields within a URL. For example, daté-óf-bírth becomes dateofbirth.

Addons

You can link to the order form with preselected addons using a URL like this:

http://example.com/whmcs/cart.php?a=add&pid=1&addons[1]

The number is the ID of the addon that you specified.

You can add multiple addons in this format:

http://example.com/whmcs/cart.php?a=add&pid=1&addons[1]&addons[2]

Setting the Language or Template via the URL

You can set the language or template to display to the user with the link you use. For example:

http://example.com/whmcs/index.php?systpl=portal
http://example.com/whmcs/index.php?language=Spanish
http://example.com/whmcs/index.php?systpl=portal&language=Spanish
http://example.com/whmcs/cart.php?systpl=portal&language=English&gid=1
http://example.com/whmcs/cart.php?systpl=portal&language=Spanish&a=add&pid=1

You can combine these, use them on any page, and use them with the direct order links.

You can link to the order form with a preselected currency (and, optionally, a language) using a URL like this:

DescriptionURL
Selecting currency ID 1.http://example.com/whmcs/cart.php?currency=1
Selecting currency ID 2 and setting the language to Spanishhttp://example.com/whmcs/cart.php?currency=2&language=Spanish

The ID of a currency is the unique ID for it within the tblcurrencies database table. You can find this within the database or by examing the number at the end of the URL when editing the currency within the Admin Area.

You can link to the create ticket page with a number of predefined settings, all of which are interchangeable.

DescriptionURL
Define the ticket subject.http://example.com/whmcs/submitticket.php?step=2&deptid=1&subject=Subject%20goes%20here
Define a name and email address.http://example.com/whmcs/submitticket.php?step=2&deptid=1&name=Jeff&email=jeff@example.com

Displaying Announcements on your Site

Announcements are available in RSS feed format. This is the recommended way of retrieving and displaying announcements in an external system or page.

For convenience, on a local site, you may wish to retrieve announcements directly from the database. The following code sample demonstrates one method:

    <?php

    use WHMCS\Database\Capsule;

    require_once 'members/init.php';

    $data = Capsule::table('tblannouncements')
                ->where('published', '!=', '0')
                ->where('published', '!=', '')
                ->orderBy('date', 'DESC')
                ->limit(3)
                ->get();

    foreach ($data as $announcement) {
        $id = $announcement->id;
        $date = $announcement->date;
        $title = $announcement->title;
        $body = $announcement->announcement;

        $date = fromMySQLDate($date);

        echo "<strong>{$title}</strong><br />"
            . "Posted on {$date}<br /><br />"
            . $body . "<br /><br />";
    }

This code assumes that you store WHMCS in the members subdirectory. Update the file include path for your setup.

Last modified: May 28, 2024