Geolocation Hook For WHMCS

From ModulesGarden Wiki
Jump to: navigation, search


Geolocation Hook For WHMCS In A Nutshell

When it comes to providing complex solutions to the business, ModulesGarden is always within your reach. This time we would like to share with you the idea of Geolocation Hook designed for WHMCS!
Easy to create and configure, it lets you set an automatic switch of elements, such as currency and language, all adapted depending on you customers' location.

Order our free ModulesGarden Geolocation Hook For WHMCS right now!

Configuration

This tutorial will show you how to successfully set up the hook.
1. Uploading Hook

The very first step we need to take is uploading a hook file that will be called on every page of the client area in our WHMCS System. The file has to be located in includes/hooks/directory.

2. Defining Currency And Language Rules

Now our hook file can be filled with the proper relations. At first, we need to define some configuration, so it will be easy to edit hook's behaviour without going through the whole file.

 $countryToCurrency = array(
   'default' => 'USD',
   'US'      => 'USD',
   'GB'      => 'GBP',
   // NOTE: You can add more below
 );
 $countryToLanguage = array(
   'default' => 'english',
   'US'    => 'english',
   'DE'    => 'german',
   'NO'    => 'norwegian'
   // NOTE: You can add more below
 );

3. Defining Additional Template Per Country And Language Rules

We can now configure additional settings and these are templates per country and language rules.

 $countryToTemplate = array(
   'US'  => 'six',
   'default' => 'six',
   // NOTE: You can add more below
 );
 /** 
* Please note that a template available in WHMCS V7 is: 'six'.
* In WHMCS V6 there are templates: 'six' and 'five'.
* It is important to use a template that exists within your WHMCS system.
* You must not mix up these two groups together.
*/
 $templateToLanguage = array(
   'english'  => 'six',
   'german'  => 'five',
   'default' => 'six',
   // NOTE: You can add more below
 );

4. Selecting Pages

At this point we can select pages at which our hook should be active.

 $allowedScripts = array(
   'p1.php',
   'index.php',
   'clientarea.php',
   'cart.php',
   'knowledgebase.php',
   'announcements.php',
   'serverstatus.php',
   'affiliates.php',
   'contact.php'
   // NOTE: You can add more below
 );

5. Getting Country With MaxMind GeoIP2

The example below shows the integration with MaxMind GeoIP2.

 /**
* Get Country using external service - MaxMind GeoIP2 Example
* http://dev.maxmind.com/geoip/
* NOTE: You can create your own submodule.
*/
 $submodule = 'GeoIP2';

6. Determining Template Setup

We will use the following code to determine whether a current template is set up correctly.

 /**
* Currency Session Setup
*/
 $allowCurrencySession = true;
 /**
* Setting up a template to redirect depending on a country
*/
 $allowRedirectCountryToTemplate = false;
 /**
* Setting up a template to redirect depending on a country
*/
 $allowRedirectLanguageToTemplate = true;

7. Creating URL Redirection

Using the below code the system will be forced to switch the client area template depending on the chosen language. It will also work for already logged in users.
Redirection needs to be executed when switching the language is done by a user or together with changing the language.

 /**
* Setting up URL redirection to allow the user to switch a language
*/
 $allowURLRedirection = true;
 /**
* Change template if
* - current template is NOT correct for this language
* - current template is NOT default if no language was chosen
*/
 $changeTemplateByLanguage = true;
 /**
* Preventing from switching currency by user
*/
 $preventSwitchCurrency = true;
 /**
* Preserve Template
* This option, when set as false, allows template switch along with the language change
*/
 $preserveTemplate = true;

Still not sure whether to get this product?

Taking all the above into consideration we can easily say that our Geolocation Hook For WHMCS, with its automatic setup of currency and language, will allow you to smoothly adjust any offer to the individual needs of each of your client.
So let's make your business even more personal!

In the meantime, you are more than welcome to visit our Blog article where you can take part in a live discussion about it.
Personal tools
Namespaces

Variants
Actions
Navigation
WHMCS Modules
cPanel Modules
Magento Extensions
Magento Themes
PrestaShop Modules
Blesta Extensions
General
Social