Difference between revisions of "Linking to WHMCS"

From WHMCS Documentation

(Configurable Options)
Line 1: Line 1:
It is very common for users of WHMCS to want to link to WHMCS from their website.  This can be in the form of an order link, or with a form that either takes the user straight to the domain checking process to check the availability of the domain they want or to login.
+
Linking to your WHMCS system, be it a login link for the client area, a shortcut to a ticket submission form or an order form purchase link, is probably one of the first things you'll want to do.  And it's both very easy, and very flexible with WHMCS.  In this article we demonstrate some of the common links & techniques you might want to make use of:
  
With WHMCS, this is made easy as all the code you need is provided to you customised and ready to insert into your website by simply going to Utilities > Integration Code.
+
For integrating a domain availability check, login form or domain purchase link, please refer to '''Utilities > Integration Code''' within your WHMCS admin area for "copy & paste" ready code.
 +
 
 +
You may also want to refer to the [[Data Feeds]] functionality.
  
 
==Order Links==
 
==Order Links==
Line 64: Line 66:
 
==Setting the Language/Template via the URL==
 
==Setting the Language/Template via the URL==
  
You can set the language or template to be displayed to the user with the link you use to WHMCS.  This is done with links such as:
+
You can set the language or template to be displayed to the user with the link you use to WHMCS.  Here are some examples:
  
 
  http://demo.whmcs.com/index.php?systpl=portal
 
  http://demo.whmcs.com/index.php?systpl=portal
 
 
  http://demo.whmcs.com/index.php?language=Spanish
 
  http://demo.whmcs.com/index.php?language=Spanish
 
 
  http://demo.whmcs.com/index.php?systpl=portal&language=Spanish
 
  http://demo.whmcs.com/index.php?systpl=portal&language=Spanish
 
 
  http://demo.whmcs.com/cart.php?systpl=portal&language=English&gid=1
 
  http://demo.whmcs.com/cart.php?systpl=portal&language=English&gid=1
 
 
  http://demo.whmcs.com/cart.php?systpl=portal&language=Spanish&a=add&pid=1
 
  http://demo.whmcs.com/cart.php?systpl=portal&language=Spanish&a=add&pid=1
  
Line 80: Line 78:
 
==Specifying Currency in a link==
 
==Specifying Currency in a link==
  
You can link to the order form with a specific currency by simulating what the form shown for currency selection does:
+
You can link to the order form pre-selecting a specific currency (and optionally also a language) using an url format as follows:
  
 
  http://demo.whmcs.com/index.php?cart.php?currency=1
 
  http://demo.whmcs.com/index.php?cart.php?currency=1
 
+
  http://demo.whmcs.com/index.php?cart.php?currency=2&language=Spanish
  http://demo.whmcs.com/index.php?cart.php?currency=1&language=Spanish
 
  
 
==Support Ticket Links==
 
==Support Ticket Links==
Line 90: Line 87:
 
You can link to the create ticket page with a number of predefined settings. All of which are interchangeable:
 
You can link to the create ticket page with a number of predefined settings. All of which are interchangeable:
  
To define the support department, client name and email address you can use a link like this:
+
To define the ticket subject, use a link like this:
 +
 
 +
  http://demo.whmcs.com/submitticket.php?step=2&deptid=1&subject=Subject%20goes%20here...
 +
 
 +
You can also go even further and define a name and email address too if you want:
  
 
  http://demo.whmcs.com/submitticket.php?step=2&deptid=1&name=Jeff&email=jeff@example.com
 
  http://demo.whmcs.com/submitticket.php?step=2&deptid=1&name=Jeff&email=jeff@example.com
  
To define the ticket subject and message, use a link like this:
+
==Integrating The Login Form into your Website==
 +
 
 +
You can display the login form on any page of your site using the code below.  This will display the required login form to login to the WHMCS Client Area.
 +
 
 +
<pre>
 +
<form method="post" action="http://www.yourdomain.com/whmcs/dologin.php">
 +
Email Address: <input type="text" name="username" size="50" />
 +
Password: <input type="password" name="password" size="20" />
 +
<input type="submit" value="Login" />
 +
</form>
 +
</pre>
 +
 
 +
You should replace the URL of the form action to the path to your WHMCS directory.
 +
 
 +
==Integration a Domain Availability Check into your Website==
  
  http://demo.whmcs.com/submitticket.php?step=2&subject=Questions&message=Your_message_here
+
Please refer to '''Utilities > Integration Code''' within your WHMCS admin area for "copy & paste" ready code for adding a domain lookup form to any page of your site.
  
==Showing Announcements on your Site==
+
==Displaying Announcements on your Site==
  
 
You can display the announcements on any page of your site using the code below.  This will display the latest 3 announcements set to published status.  
 
You can display the announcements on any page of your site using the code below.  This will display the latest 3 announcements set to published status.  
Line 108: Line 123:
 
  $result = mysql_query($query);
 
  $result = mysql_query($query);
 
  while ($data = mysql_fetch_array($result)) {
 
  while ($data = mysql_fetch_array($result)) {
  $id = $data["id"];
+
    $id = $data["id"];
  $date = $data["date"];
+
    $date = $data["date"];
  $title = $data["title"];
+
    $title = $data["title"];
  $announcement = $data["announcement"];
+
    $announcement = $data["announcement"];
  <nowiki>$date = fromMySQLDate($date);
+
    $date = fromMySQLDate($date);
  echo("<p><font color=#cccccc>$date</font> - <b>$title</b><br>$announcement</p>");</nowiki>
+
    <nowiki>echo("<p><font color="#cccccc">$date</font> - <b>$title</b><br>$announcement</p>");</nowiki>
 
  }
 
  }
 
  ?>
 
  ?>
  
 
You should replace the word support in the first two lines where it includes files from the WHMCS folder with the path to your WHMCS directory.
 
You should replace the word support in the first two lines where it includes files from the WHMCS folder with the path to your WHMCS directory.
 
==Showing The Login Form on your Site==
 
 
You can display the login form on any page of your site using the code below.  This will display the required login form to login to the WHMCS Client Area.
 
 
<pre>
 
<form method="post" action="http://www.yourdomain.com/whmcs/dologin.php">
 
Email Address: <input type="text" name="username" size="50">
 
Password: <input type="password" name="password" size="20">
 
<input type="submit" value="Login">
 
</form>
 
</pre>
 
 
You should replace the URL of the form action to the path to your WHMCS directory.
 

Revision as of 01:49, 28 October 2011

Linking to your WHMCS system, be it a login link for the client area, a shortcut to a ticket submission form or an order form purchase link, is probably one of the first things you'll want to do. And it's both very easy, and very flexible with WHMCS. In this article we demonstrate some of the common links & techniques you might want to make use of:

For integrating a domain availability check, login form or domain purchase link, please refer to Utilities > Integration Code within your WHMCS admin area for "copy & paste" ready code.

You may also want to refer to the Data Feeds functionality.

Order Links

You can obtain direct order links for products from the product configuration screen. A direct order link takes the user straight into step two of the order process with the product or service preselected. This is used for order links on your site for specific products. The link looks something like this:

http://demo.whmcs.com/cart.php?a=add&pid=1

To link to the order process with a given product and annual billing cycle preselected, you can use a link like this:

http://demo.whmcs.com/cart.php?a=add&pid=1&billingcycle=annually

To link to the order process with a domain preselected, you can use a link like this:

http://demo.whmcs.com/cart.php?sld=google&tld=.com

To link to the order process with a subdomain preselected, you can use a link like this:

http://demo.whmcs.com/cart.php?domainoption=subdomain&sld=google

To automatically apply a promotion code to the order, you can append &promocode=xxxx to any of the cart links, but on it's own the link would look like this:

http://demo.whmcs.com/cart.php?promocode=xxxxxxx

You can also link directly to an individual product group like this where the gid is the ID of the group to show:

http://demo.whmcs.com/cart.php?gid=1

To link to the cart and specify a specific order form template to use, the link would be like this where boxes is the template to display:

http://demo.whmcs.com/cart.php?carttpl=boxes

Configurable Options & Custom Fields

There are many further options you can use, such as your own configurable options. The simplest way of formulating a url is to step through the order process as normal to the product configuration step, then right click > view source and get the field names and value IDS. These can then be used in your direct link URLs.

For example:

<p class="cartsubheading">Configurable Options</p>
<p>This product/service has some options which you can choose from below 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 the URL:

http://demo.whmcs.com/cart.php?a=add&pid=1&configoption[1]=100

This would set the value of the first configurable option to 100.

Custom fields are almost exactly the same, the following would pre-fill the first custom field option with the value "Friday":

 http://demo.whmcs.com/cart.php?a=add&pid=5&customfield[1]=Friday

Setting the Language/Template via the URL

You can set the language or template to be displayed to the user with the link you use to WHMCS. Here are some examples:

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

These can be combined, used on any page and used with the direct order links

Specifying Currency in a link

You can link to the order form pre-selecting a specific currency (and optionally also a language) using an url format as follows:

http://demo.whmcs.com/index.php?cart.php?currency=1
http://demo.whmcs.com/index.php?cart.php?currency=2&language=Spanish

Support Ticket Links

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

To define the ticket subject, use a link like this:

 http://demo.whmcs.com/submitticket.php?step=2&deptid=1&subject=Subject%20goes%20here...

You can also go even further and define a name and email address too if you want:

http://demo.whmcs.com/submitticket.php?step=2&deptid=1&name=Jeff&email=jeff@example.com

Integrating The Login Form into your Website

You can display the login form on any page of your site using the code below. This will display the required login form to login to the WHMCS Client Area.

<form method="post" action="http://www.yourdomain.com/whmcs/dologin.php">
Email Address: <input type="text" name="username" size="50" />
Password: <input type="password" name="password" size="20" />
<input type="submit" value="Login" />
</form> 

You should replace the URL of the form action to the path to your WHMCS directory.

Integration a Domain Availability Check into your Website

Please refer to Utilities > Integration Code within your WHMCS admin area for "copy & paste" ready code for adding a domain lookup form to any page of your site.

Displaying Announcements on your Site

You can display the announcements on any page of your site using the code below. This will display the latest 3 announcements set to published status.

<?php
include("support/dbconnect.php");
include("support/includes/functions.php");
$query = "SELECT * FROM tblannouncements WHERE published='on' ORDER BY date DESC LIMIT 0,3"; 
$result = mysql_query($query);
while ($data = mysql_fetch_array($result)) {
    $id = $data["id"];
    $date = $data["date"];
    $title = $data["title"];
    $announcement = $data["announcement"];
    $date = fromMySQLDate($date);
    echo("<p><font color="#cccccc">$date</font> - <b>$title</b><br>$announcement</p>");
}
?>

You should replace the word support in the first two lines where it includes files from the WHMCS folder with the path to your WHMCS directory.