Difference between revisions of "Linking to WHMCS"
(→Order Links) |
|||
(54 intermediate revisions by 7 users not shown) | |||
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. | ||
− | == | + | <div class="docs-alert-info"> |
+ | The examples below use a WHMCS installation at <tt><nowiki>http://www.example.com/whmcs</nowiki></tt>. | ||
+ | </div> | ||
+ | |||
+ | ===Client Area and Shopping Cart Links=== | ||
− | + | To link to the Client Area, allowing the user to manage their client account: | |
+ | <nowiki>http://www.example.com/whmcs/clientarea.php</nowiki> | ||
+ | If the user is not already logged in, this link will first direct them to a login prompt. | ||
− | http:// | + | To link directly to the active shopping cart: |
+ | <nowiki>http://www.example.com/whmcs/cart.php</nowiki> | ||
+ | This link will go directly to the default product group. | ||
− | + | ==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 and Services|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. | |
− | + | ||
− | + | ===Product Link Tab Links=== | |
− | + | ||
− | + | [[File:link-tab-urls-83.png|thumb|]] | |
− | + | ||
− | + | 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, if applicable. | |
− | + | * '''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]]. | ||
+ | |||
+ | ===Constructing Additional Links=== | ||
+ | |||
+ | <div class="docs-alert-info"> | ||
+ | All of these examples begin with the '''Direct Shopping Cart Link''' URL described above. | ||
+ | </div> | ||
− | http:// | + | 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 | + | 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> | ||
− | + | 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> | ||
− | To | + | 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> | ||
− | + | 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 at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Products and Services|Products/Services]]''' or, prior to WHMCS 8.0, '''Setup > Products/Services > Products/Services''': | |
+ | <nowiki> http://example.com/whmcs/cart.php?gid=1</nowiki> | ||
+ | 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> | ||
− | + | 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> | |
− | |||
− | |||
− | |||
+ | ===Configurable Options=== | ||
+ | |||
+ | You can also create your own [[Configurable Options|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: | ||
+ | |||
<nowiki><p class="cartsubheading">Configurable Options</p> | <nowiki><p class="cartsubheading">Configurable Options</p> | ||
− | <p>This product | + | <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 54: | Line 87: | ||
</td></tr> | </td></tr> | ||
</table> | </table> | ||
− | </div> | + | </div></nowiki> |
− | </nowiki> | + | |
+ | You would then use this URL: | ||
+ | <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 <tt>100</tt>. | ||
− | + | ===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 <tt>Friday</tt>: | ||
− | + | <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, 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> | |
− | + | <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=== |
+ | |||
+ | 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> | ||
− | + | The number is the ID of the addon you specified. | |
+ | |||
+ | You can add multiple addons in this format: | ||
+ | |||
+ | <nowiki>http://example.com/whmcs/cart.php?a=add&pid=1&addons[1]&addons[2]</nowiki> | ||
− | http:// | + | ==Setting the Language or Template via the URL== |
− | http:// | + | |
− | http:// | + | You can set the language or template to display to the user with the link you use. Here are some examples: |
− | http:// | + | |
− | http:// | + | <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?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. | |
==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: | ||
+ | |||
+ | '''Selecting Currency ID 1''' | ||
+ | |||
+ | <nowiki>http://example.com/whmcs/cart.php?currency=1</nowiki> | ||
− | + | '''Selecting Currency ID 2 and the Spanish language''' | |
+ | |||
+ | <nowiki>http://example.com/whmcs/cart.php?currency=2&language=Spanish</nowiki> | ||
− | + | The ID of a currency is the unique ID for it within the <tt>tblcurrencies</tt> 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== | ==Support Ticket Links== | ||
− | + | ||
− | You can link to the create ticket page with a number of predefined settings | + | 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> | |
− | + | You can also define a name and email address: | |
− | You can also | + | |
− | + | <nowiki>http://example.com/whmcs/submitticket.php?step=2&deptid=1&name=Jeff&email=jeff@example.com</nowiki> | |
− | http:// | ||
− | |||
==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 <tt>dologin.php</tt>, the line below must be added to the <tt>configuration.php</tt> file: | ||
− | + | <nowiki>$allow_external_login_forms = true;</nowiki> | |
− | |||
− | = | ||
− | |||
− | |||
+ | ==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. | |
− | + | ||
− | + | 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"> | |
− | + | <?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 />"; | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | This code assumes that you store WHMCS in the <tt>members</tt> subdirectory. Update the file include path for your setup. |
Latest revision as of 21:33, 28 November 2022
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.
The examples below use a WHMCS installation at http://www.example.com/whmcs.
Contents
- 1 Client Area and Shopping Cart Links
- 2 Cart and Product Links
- 3 Setting the Language or Template via the URL
- 4 Specifying Currency in a link
- 5 Support Ticket Links
- 6 Integrating The Login Form into your Website
- 7 Integrating a Domain Availability Check into your Website
- 8 Displaying Announcements on your Site
Client Area and Shopping Cart Links
To link to the Client Area, allowing the user to manage their client account:
http://www.example.com/whmcs/clientarea.php
If the user is not already logged in, this link will first direct them to a login prompt.
To link directly to the active shopping cart:
http://www.example.com/whmcs/cart.php
This link will go directly to the default product group.
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.
Product Link 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, if applicable.
- 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.
Constructing Additional Links
All of these examples begin with the Direct Shopping Cart Link URL described above.
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 at Configuration () > System Settings > Products/Services or, prior to WHMCS 8.0, Setup > Products/Services > Products/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
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 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
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.
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.