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.
http://www.example.com/whmcs
.Links
You can use the following URLs to link to WHMCS:
Area | Example Link | Description |
---|---|---|
Client Area | http://www.example.com/whmcs/clientarea.php | A 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 Cart | http://www.example.com/whmcs/cart.php | A link to the active shopping cart. |
Individual Products | http://www.example.com/whmcs/store/shared-hosting/starter | A 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. |
Product Links
You can find the links for each product in the Links tab when you edit the product at Configuration () > System Settings > Products/Services:
You can copy the following direct links for the product and its associated group:
URL | Description |
---|---|
Direct Shopping Cart Link | Add the product to the shopping cart and direct the visitor to the configuration page. |
Direct Shopping Cart Link Specifying Template | Add 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 Domain | Add the product to the shopping cart and direct the visitor to the domain selection page. |
Product Group Cart Link | Direct the visitor to the product group page. |
Product URLs | Direct 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.
|
Constructing Links
You can append additional variables and values onto links to customize them:
Variable or Value | Description | Example Link |
---|---|---|
billingcycle | Link to a preselected product with an annual billing cycle. | http://example.com/whmcs/cart.php?a=add&pid=1&billingcycle=annually |
sld and tld | Link 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 sld | Link to a preselected product with a subdomain. | http://example.com/whmcs/cart.php?a=add&pid=1&domainoption=subdomain&sld=google |
promocode | Link to the shopping cart and automatically apply a promotion code. | http://example.com/whmcs/cart.php?promocode=xxxxxxx |
gid | Link to a product group using the product group ID (gid ). | http://example.com/whmcs/cart.php?gid=1 |
carttpl | Link to the shopping cart and specify an order form template to use. | http://example.com/whmcs/cart.php?carttpl=boxes |
bid | Link 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:
- Step through the order process normally until you reach the product configuration step.
- Right click and select View Source.
- 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.
Specifying Currency in a link
You can link to the order form with a preselected currency (and, optionally, a language) using a URL like this:
Description | URL |
---|---|
Selecting currency ID 1 . | http://example.com/whmcs/cart.php?currency=1 |
Selecting currency ID 2 and setting the language to Spanish | http://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.
Support Ticket Links
You can link to the create ticket page with a number of predefined settings, all of which are interchangeable.
Description | URL |
---|---|
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: November 19, 2024