Difference between revisions of "Linking to WHMCS"
Line 7: | Line 7: | ||
You can obtain direct order links for products from the product configuration in the '''Links''' tab in the '''Edit''' view at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > Products/Services''' or, prior to WHMCS 8.0, '''Setup > Products/Services > Products/Services'''. A direct order link takes the user straight into step two of the order process and preselects the product or service. Use this for order links on your site for specific products. The link looks like this: | You can obtain direct order links for products from the product configuration in the '''Links''' tab in the '''Edit''' view at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > Products/Services''' or, prior to WHMCS 8.0, '''Setup > Products/Services > Products/Services'''. A direct order link takes the user straight into step two of the order process and preselects the product or service. Use this for order links on your site for specific products. The link looks like this: | ||
− | http:// | + | http://example.com/whmcs/cart.php?a=add&pid=1 |
To link to the order process with a preselected product and annual billing cycle, you can use a link like this: | To link to the order process with a preselected product and annual billing cycle, you can use a link like this: | ||
− | http:// | + | http://example.com/whmcs/cart.php?a=add&pid=1&billingcycle=annually |
To link to the order process with a preselected domain, you can use a link like this: | To link to the order process with a preselected domain, you can use a link like this: | ||
− | http:// | + | http://example.com/whmcs/cart.php?a=add&pid=1&sld=google&tld=.com |
To link to the order process with a preselected subdomain, you can use a link like this: | To link to the order process with a preselected subdomain, you can use a link like this: | ||
− | http:// | + | http://example.com/whmcs/cart.php?a=add&pid=1&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 its own the link would look like this: | To automatically apply a promotion code to the order, you can append &promocode=xxxx to any of the cart links, but on its own the link would look like this: | ||
− | http:// | + | http://example.com/whmcs/cart.php?promocode=xxxxxxx |
You can also link directly to an individual product group, where the <tt>gid</tt> is the ID of the group to show: | You can also link directly to an individual product group, where the <tt>gid</tt> is the ID of the group to show: | ||
− | http:// | + | http://example.com/whmcs/cart.php?gid=1 |
To link to the cart and specify an order form template to use, you can use a link like this, where <tt>boxes</tt> is the template to display: | To link to the cart and specify an order form template to use, you can use a link like this, where <tt>boxes</tt> is the template to display: | ||
− | http:// | + | http://example.com/whmcs/cart.php?carttpl=boxes |
To link to a [[Product Bundles|Product Bundle]], where <tt>bid</tt> is the ID of the bundle use: | To link to a [[Product Bundles|Product Bundle]], where <tt>bid</tt> is the ID of the bundle use: | ||
− | + | http://example.com/whmcs/cart.php?a=add&bid=X | |
Line 59: | Line 59: | ||
You would then use this URL: | You would then use this URL: | ||
− | <nowiki>http:// | + | <nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&configoption[1]=100</nowiki> |
This would set the value of the first configurable option to 100. | This would set the value of the first configurable option to 100. | ||
Line 67: | Line 67: | ||
Custom product fields are almost exactly the same. The following link would prefill the custom field option, "Day of Week", with the value "Friday": | Custom product fields are almost exactly the same. The following link would prefill the custom field option, "Day of Week", with the value "Friday": | ||
− | <nowiki>http:// | + | <nowiki>http://example.com/whmcs/cart.php?a=add&pid=5&cf_dayofweek=Friday</nowiki> |
It's possible to skip the configuration page entirely if you have defined all the configuration values in the URL by adding <tt>&skipconfig=1</tt> to your order URL. If there is missing configuration data, then this would generate an error and force the client to edit the configuration. For example: | It's possible to skip the configuration page entirely if you have defined all the configuration values in the URL by adding <tt>&skipconfig=1</tt> to your order URL. If there is missing configuration data, then this would generate an error and force the client to edit the configuration. For example: | ||
− | <nowiki>http:// | + | <nowiki>http://example.com/whmcs/cart.php?a=add&pid=5&cf_dayofweek=Friday&skipconfig=1</nowiki> |
<div class="docs-alert-info">Custom field names must not contain any special characters, with the exception of underscores, in order to prefill custom fields within a URL. For example, ''daté-óf-bírth'' becomes ''dateofbirth''.</div> | <div class="docs-alert-info">Custom field names must not contain any special characters, with the exception of underscores, in order to prefill custom fields within a URL. For example, ''daté-óf-bírth'' becomes ''dateofbirth''.</div> | ||
Line 79: | Line 79: | ||
You can link to the order form with preselected addons using a URL like this: | You can link to the order form with preselected addons using a URL like this: | ||
− | <nowiki>http:// | + | <nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&addons[1]</nowiki> |
The number is the ID of the addon you specified. | The number is the ID of the addon you specified. | ||
Line 85: | Line 85: | ||
You can add multiple addons in this format: | You can add multiple addons in this format: | ||
− | <nowiki>http:// | + | <nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&addons[1]&addons[2]</nowiki> |
==Setting the Language or Template via the URL== | ==Setting the Language or Template via the URL== | ||
Line 91: | Line 91: | ||
You can set the language or template to display to the user with the link you use. Here are some examples: | You can set the language or template to display to the user with the link you use. Here are some examples: | ||
− | http:// | + | http://example.com/whmcs/index.php?systpl=portal |
− | http:// | + | http://example.com/whmcs/index.php?language=Spanish |
− | http:// | + | http://example.com/whmcs/index.php?systpl=portal&language=Spanish |
− | http:// | + | http://example.com/whmcs/cart.php?systpl=portal&language=English&gid=1 |
− | http:// | + | 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 combine these, use them on any page, and use them with the direct order links. | ||
Line 105: | Line 105: | ||
'''Selecting Currency ID 1''' | '''Selecting Currency ID 1''' | ||
− | http:// | + | http://example.com/whmcs/cart.php?currency=1 |
'''Selecting Currency ID 2 and the Spanish language''' | '''Selecting Currency ID 2 and the Spanish language''' | ||
− | http:// | + | http://example.com/whmcs/cart.php?currency=2&language=Spanish |
==Support Ticket Links== | ==Support Ticket Links== | ||
Line 117: | Line 117: | ||
To define the ticket subject, use a link like this: | To define the ticket subject, use a link like this: | ||
− | http:// | + | http://example.com/whmcs/submitticket.php?step=2&deptid=1&subject=Subject%20goes%20here... |
You can also define a name and email address: | You can also define a name and email address: | ||
− | http:// | + | http://example.com/whmcs/submitticket.php?step=2&deptid=1&name=Jeff&email=jeff@example.com |
==Integrating The Login Form into your Website== | ==Integrating The Login Form into your Website== |
Revision as of 16:18, 22 September 2020
Linking to your WHMCS system, whether it's 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 after setting up WHMCS. WHMCS makes this very easy and very flexible.
For integrating a domain availability check, login form, or domain purchase link, 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.
Contents
Order Links
You can obtain direct order links for products from the product configuration in the Links tab in the Edit view at Configuration () > System Settings > Products/Services or, prior to WHMCS 8.0, Setup > Products/Services > Products/Services. A direct order link takes the user straight into step two of the order process and preselects the product or service. Use this for order links on your site for specific products. The link looks like this:
http://example.com/whmcs/cart.php?a=add&pid=1
To link to the order process with a preselected product and annual billing cycle, you can use a link like this:
http://example.com/whmcs/cart.php?a=add&pid=1&billingcycle=annually
To link to the order process with a preselected domain, you can use a link like this:
http://example.com/whmcs/cart.php?a=add&pid=1&sld=google&tld=.com
To link to the order process with a preselected subdomain, you can use a link like this:
http://example.com/whmcs/cart.php?a=add&pid=1&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 its own the link would look like this:
http://example.com/whmcs/cart.php?promocode=xxxxxxx
You can also link directly to an individual product group, where the gid is the ID of the group to show:
http://example.com/whmcs/cart.php?gid=1
To link to the cart and specify an order form template to use, you can use a link like this, where boxes is the template to display:
http://example.com/whmcs/cart.php?carttpl=boxes
To link to a Product Bundle, where bid is the ID of the bundle use:
http://example.com/whmcs/cart.php?a=add&bid=X
Configurable Options
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 until you reach the product configuration step. Then, right click and select view source. Then, 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 this URL:
http://example.com/whmcs/cart.php?a=add&pid=1&configoption[1]=100
This would set the value of the first configurable option to 100.
Custom Fields
Custom product fields are almost exactly the same. The following link would prefill the custom field option, "Day of Week", with the value "Friday":
http://example.com/whmcs/cart.php?a=add&pid=5&cf_dayofweek=Friday
It's possible to skip the configuration page entirely if you have defined all the configuration values in the URL by adding &skipconfig=1 to your order URL. If there is missing configuration data, then 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
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 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. Here are some examples:
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:
Selecting Currency ID 1
http://example.com/whmcs/cart.php?currency=1
Selecting Currency ID 2 and the Spanish language
http://example.com/whmcs/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://example.com/whmcs/submitticket.php?step=2&deptid=1&subject=Subject%20goes%20here...
You can also define a name and email address:
http://example.com/whmcs/submitticket.php?step=2&deptid=1&name=Jeff&email=jeff@example.com
Integrating The Login Form into your Website
Refer to Utilities > Integration Code within your WHMCS admin area for copy-and-paste ready code for adding a client's login form to any page of your site.
Integrating a Domain Availability Check into your Website
Refer to Utilities > Integration Code within your WHMCS admin area for copy-and-paste ready code for adding a domain lookup form to any page of your site.
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.