Difference between revisions of "Linking to WHMCS"
m (→Integrating The Login Form into your Website) |
|||
Line 1: | Line 1: | ||
− | Linking to | + | 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 integrating a domain availability check, login form, or domain purchase link, | + | For integrating a domain availability check, login form, or domain purchase link, see '''Utilities > Integration Code''' within your WHMCS Admin Area for copy-paste ready code. You may also want to refer to the [[Data Feeds]] functionality. |
− | + | ||
− | == | + | ==Cart and Product Links== |
− | + | ||
− | + | The '''Links''' tab when you click '''Edit''' for a product 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''' displays various links to the product. You can use these links to direct clients to a specific page or to load the product into their cart and immediately take them to the configuration step for that product. | |
− | + | ||
− | + | ===Links Tab Links=== | |
− | + | ||
− | To link to | + | [[File:link-tab-urls-83.png|thumb|]] |
− | + | ||
− | <nowiki> http://example.com/whmcs/cart.php?a=add&pid=1&billingcycle=annually </nowiki> | + | You can find the following URLs here: |
− | + | ||
− | To link to | + | * '''Direct Shopping Cart Link''' — The product is added to the shopping cart and the visitor goes directly to the configuration page. |
− | + | * '''Direct Shopping Cart Link Specifying Template''' — The product is added to the shopping cart and the visitor goes directly to the configuration page using a specified template. | |
+ | * '''Direct Shopping Cart Link Including Domain''' — The product is added to the shopping cart and the visitor goes directly to the domain selection page. | ||
+ | * '''Product Group Cart Link''' — The visitor goes directly to the product group page. | ||
+ | * '''Product URLs''' — The visitor goes directly to the '''Direct Shopping Cart Link''' URL destination. | ||
+ | ** Product URLs also track the number of visits for each product URL. | ||
+ | ** When you delete a product URL, the URL will become nonfunctional. | ||
+ | |||
+ | For more information, see [[Products and Services]] and [[Friendly URLs]]. | ||
+ | |||
+ | ===Additional URLs=== | ||
+ | |||
+ | <div class="docs-alert-info">All of these examples begin with the '''Direct Shopping Cart Link''' URL described above.</div> | ||
+ | |||
+ | To link to a preselected product with an annual billing cycle, add a <tt>billingcycle</tt> value: | ||
+ | |||
+ | <nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&billingcycle=annually </nowiki> | ||
+ | |||
+ | To link to a preselected product with a domain, add <tt>sld</tt> and <tt>tld</tt> values: | ||
+ | |||
<nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&sld=google&tld=.com</nowiki> | <nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&sld=google&tld=.com</nowiki> | ||
− | + | ||
− | To link to | + | To link to a preselected product with a subdomain, add <tt>domainoption</tt> and <tt>sld</tt> values: |
− | + | ||
<nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&domainoption=subdomain&sld=google</nowiki> | <nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&domainoption=subdomain&sld=google</nowiki> | ||
− | + | ||
− | To automatically apply a promotion code to the order, | + | To automatically apply a promotion code to the order, add a <tt>promocode</tt> value alone or with any of the cart links: |
− | + | ||
<nowiki>http://example.com/whmcs/cart.php?promocode=xxxxxxx</nowiki> | <nowiki>http://example.com/whmcs/cart.php?promocode=xxxxxxx</nowiki> | ||
− | + | ||
− | + | To link directly to an individual product group, add a <tt>gid</tt> value with the ID of the product group, or use the URL specified in [[Products and Services]]: | |
− | + | ||
<nowiki> http://example.com/whmcs/cart.php?gid=1</nowiki> | <nowiki> http://example.com/whmcs/cart.php?gid=1</nowiki> | ||
− | + | ||
− | To link to the cart and specify an order form template to use, | + | To link to the cart and specify an order form template to use, add a <tt>carttpl</tt> value with the order form template name: |
− | + | ||
<nowiki> http://example.com/whmcs/cart.php?carttpl=boxes</nowiki> | <nowiki> http://example.com/whmcs/cart.php?carttpl=boxes</nowiki> | ||
− | + | ||
− | To link to a [[Product Bundles| | + | To link to a [[Product Bundles|product bundle]], add a <tt>bid</tt> value with the ID of the bundle: |
− | + | ||
<nowiki> http://example.com/whmcs/cart.php?a=add&bid=X</nowiki> | <nowiki> http://example.com/whmcs/cart.php?a=add&bid=X</nowiki> | ||
− | + | ||
− | + | ||
===Configurable Options=== | ===Configurable Options=== | ||
− | + | ||
− | + | You can also create your own [[Addons_and_Configurable_Options|configurable options]]. | |
− | + | ||
− | For example: | + | 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: | ||
+ | |||
<nowiki><p class="cartsubheading">Configurable Options</p> | <nowiki><p class="cartsubheading">Configurable Options</p> | ||
<p>This product or service has some options that you can choose to customise your | <p>This product or service has some options that you can choose to customise your | ||
order.</p> | order.</p> | ||
− | + | ||
<div class="cartbox"> | <div class="cartbox"> | ||
<table cellspacing="0" cellpadding="0"> | <table cellspacing="0" cellpadding="0"> | ||
Line 56: | Line 80: | ||
</div> | </div> | ||
</nowiki> | </nowiki> | ||
− | + | ||
You would then use this URL: | You would then use this URL: | ||
− | + | ||
<nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&configoption[1]=100</nowiki> | <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 <tt>100</tt>. |
− | + | ||
===Custom Fields=== | ===Custom Fields=== | ||
− | + | ||
− | Custom product fields are almost exactly the same. The following link would prefill the custom field option, | + | Custom product fields are almost exactly the same. The following link would prefill the custom field option, the day of the week, with the value <tt>Friday</tt>: |
− | + | ||
<nowiki>http://example.com/whmcs/cart.php?a=add&pid=5&cf_dayofweek=Friday</nowiki> | <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, | + | 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, this would generate an error and force the client to edit the configuration. For example: |
− | + | ||
<nowiki>http://example.com/whmcs/cart.php?a=add&pid=5&cf_dayofweek=Friday&skipconfig=1</nowiki> | <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 | + | <div class="docs-alert-info">Custom field names must not contain any special characters other than underscores in order to prefill custom fields within a URL. For example, <tt>daté-óf-bírth</tt> becomes <tt>dateofbirth</tt>.</div> |
− | + | ||
===Addons=== | ===Addons=== | ||
− | + | ||
− | 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://example.com/whmcs/cart.php?a=add&pid=1&addons[1]</nowiki> | <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. | ||
− | + | ||
You can add multiple addons in this format: | You can add multiple addons in this format: | ||
− | + | ||
<nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&addons[1]&addons[2]</nowiki> | <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== | ||
− | + | ||
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: | ||
− | + | ||
<nowiki> http://example.com/whmcs/index.php?systpl=portal</nowiki> | <nowiki> http://example.com/whmcs/index.php?systpl=portal</nowiki> | ||
<nowiki> http://example.com/whmcs/index.php?language=Spanish</nowiki> | <nowiki> http://example.com/whmcs/index.php?language=Spanish</nowiki> | ||
− | + | <nowiki>http://example.com/whmcs/index.php?systpl=portal&language=Spanish</nowiki> | |
− | + | <nowiki>http://example.com/whmcs/cart.php?systpl=portal&language=English&gid=1</nowiki> | |
− | + | <nowiki>http://example.com/whmcs/cart.php?systpl=portal&language=Spanish&a=add&pid=1</nowiki> | |
− | + | ||
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. | ||
− | + | ||
==Specifying Currency in a link== | ==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: | You can link to the order form with a preselected currency (and, optionally, a language) using a URL like this: | ||
− | + | ||
'''Selecting Currency ID 1''' | '''Selecting Currency ID 1''' | ||
− | + | ||
<nowiki>http://example.com/whmcs/cart.php?currency=1</nowiki> | <nowiki>http://example.com/whmcs/cart.php?currency=1</nowiki> | ||
− | + | ||
'''Selecting Currency ID 2 and the Spanish language''' | '''Selecting Currency ID 2 and the Spanish language''' | ||
− | + | ||
<nowiki>http://example.com/whmcs/cart.php?currency=2&language=Spanish</nowiki> | <nowiki>http://example.com/whmcs/cart.php?currency=2&language=Spanish</nowiki> | ||
− | + | ||
==Support Ticket Links== | ==Support Ticket Links== | ||
− | + | ||
− | 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 ticket subject, use a link like this: | To define the ticket subject, use a link like this: | ||
− | + | ||
<nowiki> http://example.com/whmcs/submitticket.php?step=2&deptid=1&subject=Subject%20goes%20here...</nowiki> | <nowiki> http://example.com/whmcs/submitticket.php?step=2&deptid=1&subject=Subject%20goes%20here...</nowiki> | ||
− | + | ||
You can also define a name and email address: | You can also define a name and email address: | ||
− | + | ||
<nowiki>http://example.com/whmcs/submitticket.php?step=2&deptid=1&name=Jeff&email=jeff@example.com</nowiki> | <nowiki>http://example.com/whmcs/submitticket.php?step=2&deptid=1&name=Jeff&email=jeff@example.com</nowiki> | ||
− | + | ||
==Integrating The Login Form into your Website== | ==Integrating The Login Form into your Website== | ||
− | + | ||
− | + | See '''Utilities > Integration Code''' in the WHMCS Admin Area for copy-and-paste ready code for adding a client's login form to any page of your site. | |
− | + | ||
− | In WHMCS version 8.1 and above, enhanced security around login forms means that to leverage an external login form that posts data to dologin.php, the line below must be added to the configuration.php file: | + | In WHMCS version 8.1 and above, enhanced security around login forms means that to leverage an external login form that posts data to <tt>dologin.php</tt>, the line below must be added to the <tt>configuration.php</tt> file: |
− | + | ||
<nowiki>$allow_external_login_forms = true;</nowiki> | <nowiki>$allow_external_login_forms = true;</nowiki> | ||
− | + | ||
==Integrating a Domain Availability Check into your Website== | ==Integrating a Domain Availability Check into your Website== | ||
− | + | ||
− | + | See '''Utilities > Integration Code''' within the 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== | ==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. | 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: | For convenience, on a local site, you may wish to retrieve announcements directly from the database. The following code sample demonstrates one method: | ||
− | + | ||
<source lang="php"> | <source lang="php"> | ||
<?php | <?php | ||
− | + | ||
use WHMCS\Database\Capsule; | use WHMCS\Database\Capsule; | ||
− | + | ||
require_once 'members/init.php'; | require_once 'members/init.php'; | ||
− | + | ||
$data = Capsule::table('tblannouncements') | $data = Capsule::table('tblannouncements') | ||
->where('published', '!=', '0') | ->where('published', '!=', '0') | ||
Line 154: | Line 178: | ||
->limit(3) | ->limit(3) | ||
->get(); | ->get(); | ||
− | + | ||
foreach ($data as $announcement) { | foreach ($data as $announcement) { | ||
$id = $announcement->id; | $id = $announcement->id; | ||
Line 160: | Line 184: | ||
$title = $announcement->title; | $title = $announcement->title; | ||
$body = $announcement->announcement; | $body = $announcement->announcement; | ||
− | + | ||
$date = fromMySQLDate($date); | $date = fromMySQLDate($date); | ||
− | + | ||
echo "<strong>{$title}</strong><br />" | echo "<strong>{$title}</strong><br />" | ||
. "Posted on {$date}<br /><br />" | . "Posted on {$date}<br /><br />" | ||
. $body . "<br /><br />"; | . $body . "<br /><br />"; | ||
− | } | + | } |
</source> | </source> | ||
− | + | ||
− | This code assumes that you store WHMCS in the | + | This code assumes that you store WHMCS in the <tt>members</tt> subdirectory. Update the file include path for your setup. |
Revision as of 17:37, 13 September 2021
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 integrating a domain availability check, login form, or domain purchase link, see 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
Cart and Product Links
The Links tab when you click Edit for a product at Configuration () > System Settings > Products/Services or, prior to WHMCS 8.0, Setup > Products/Services > Products/Services displays various links to the product. You can use these links to direct clients to a specific page or to load the product into their cart and immediately take them to the configuration step for that product.
Links Tab Links
You can find the following URLs here:
- Direct Shopping Cart Link — The product is added to the shopping cart and the visitor goes directly to the configuration page.
- Direct Shopping Cart Link Specifying Template — The product is added to the shopping cart and the visitor goes directly to the configuration page using a specified template.
- Direct Shopping Cart Link Including Domain — The product is added to the shopping cart and the visitor goes directly to the domain selection page.
- Product Group Cart Link — The visitor goes directly to the product group page.
- Product URLs — The visitor goes directly to the Direct Shopping Cart Link URL destination.
- Product URLs also track the number of visits for each product URL.
- When you delete a product URL, the URL will become nonfunctional.
For more information, see Products and Services and Friendly URLs.
Additional URLs
To link to a preselected product with an annual billing cycle, add a billingcycle value:
http://example.com/whmcs/cart.php?a=add&pid=1&billingcycle=annually
To link to a preselected product with a domain, add sld and tld values:
http://example.com/whmcs/cart.php?a=add&pid=1&sld=google&tld=.com
To link to a preselected product with a subdomain, add domainoption and sld values:
http://example.com/whmcs/cart.php?a=add&pid=1&domainoption=subdomain&sld=google
To automatically apply a promotion code to the order, add a promocode value alone or with any of the cart links:
http://example.com/whmcs/cart.php?promocode=xxxxxxx
To link directly to an individual product group, add a gid value with the ID of the product group, or use the URL specified in Products and Services:
http://example.com/whmcs/cart.php?gid=1
To link to the cart and specify an order form template to use, add a carttpl value with the order form template name:
http://example.com/whmcs/cart.php?carttpl=boxes
To link to a product bundle, add a bid value with the ID of the bundle:
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 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, the day of the 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, 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
See Utilities > Integration Code in the WHMCS Admin Area for copy-and-paste ready code for adding a client's login form to any page of your site.
In WHMCS version 8.1 and above, enhanced security around login forms means that to leverage an external login form that posts data to dologin.php, the line below must be added to the configuration.php file:
$allow_external_login_forms = true;
Integrating a Domain Availability Check into your Website
See Utilities > Integration Code within the 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.