Difference between revisions of "Linking to WHMCS"
(→Setting the Language or Template via the URL) |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
* 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. | * 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. | * 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=== | ===Client Area and Shopping Cart Links=== | ||
Line 8: | Line 12: | ||
To link to the Client Area, allowing the user to manage their client account: | To link to the Client Area, allowing the user to manage their client account: | ||
<nowiki>http://www.example.com/whmcs/clientarea.php</nowiki> | <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. | |
To link directly to the active shopping cart: | To link directly to the active shopping cart: | ||
<nowiki>http://www.example.com/whmcs/cart.php</nowiki> | <nowiki>http://www.example.com/whmcs/cart.php</nowiki> | ||
+ | This link will go directly to the default product group. | ||
==Cart and Product Links== | ==Cart and Product Links== | ||
Line 23: | Line 28: | ||
You can find the following URLs here: | 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''' — 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 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. | * '''Direct Shopping Cart Link Including Domain''' — The product is added to the shopping cart and the visitor goes directly to the domain selection page. | ||
Line 83: | Line 88: | ||
</table> | </table> | ||
</div></nowiki> | </div></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> | ||
Line 107: | Line 112: | ||
<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. | ||
Line 133: | Line 138: | ||
<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''' | ||
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.