Geolocation Hook For WHMCS
Katarzyna.pa (Talk | contribs) |
Katarzyna.pa (Talk | contribs) |
||
Line 6: | Line 6: | ||
{| | {| | ||
|style="padding: 10px 0px 10px 0px;"|'''Geolocation Hook For WHMCS''' | |style="padding: 10px 0px 10px 0px;"|'''Geolocation Hook For WHMCS''' | ||
− | When it comes to providing complex solutions to the business, ModulesGarden is always within your reach. This time we would like to share the idea of Geolocation Hook with you!<br/>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. | + | When it comes to providing complex solutions to the business, ModulesGarden is always within your reach. This time we would like to share the idea of Geolocation Hook with you!<br/>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.<br/><br/> |
+ | '''[https://www.modulesgarden.com/products/whmcs/geolocation-hook Order ModulesGarden Geolocation Hook For WHMCS right now!]''' | ||
|} | |} | ||
+ | =Configuration= | ||
+ | {| | ||
+ | |style="padding: 10px 0px 0px 0px;"|'''This tutorial will show you how to successfully set up the hook.''' | ||
+ | |} | ||
+ | {| | ||
+ | |style="padding: 20px 0px 20px 15px;"|'''1. Uploading Hook'''<br/> | ||
+ | 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. | ||
+ | |} | ||
+ | {| | ||
+ | |style="padding: 0px 0px 15px 15px;"|'''2. Defining Currency And Language Rules'''<br/> | ||
+ | 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. | ||
− | + | <code> | |
+ | $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 | ||
+ | ); | ||
+ | </code> | ||
+ | |} | ||
+ | {| | ||
+ | |style="padding: 0px 0px 15px 15px;"|'''3. Defining Additional Template Per Country And Language Rules'''<br/> | ||
+ | We can now configure additional settings and these are templates per country and language rules. | ||
− | In the meantime, you are more than welcome to visit our [https://www.blog.modulesgarden.com/automatic-currency-and-language-setup-for-whmcs/ Blog] where you can also check out other interesting articles. | + | <code> |
+ | $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 | ||
+ | ); | ||
+ | </code> | ||
+ | |} | ||
+ | {| | ||
+ | |style="padding: 0px 0px 15px 15px;"|'''4. Selecting Pages'''<br/> | ||
+ | At this point we can select pages at which our hook should be active. | ||
+ | |||
+ | <code> | ||
+ | $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 | ||
+ | ); | ||
+ | </code> | ||
+ | |} | ||
+ | {| | ||
+ | |style="padding: 0px 0px 15px 15px;"|'''5. Getting Country With MaxMind GeoIP2'''<br/> | ||
+ | The example below shows the integration with MaxMind GeoIP2. | ||
+ | |||
+ | <code> | ||
+ | /** | ||
+ | * Get Country using external service - MaxMind GeoIP2 Example | ||
+ | * http://dev.maxmind.com/geoip/ | ||
+ | * NOTE: You can create your own submodule. | ||
+ | */ | ||
+ | $submodule = 'GeoIP2'; | ||
+ | </code> | ||
+ | |} | ||
+ | {| | ||
+ | |style="padding: 0px 0px 15px 15px;"|'''6. Determining Template Setup'''<br/> | ||
+ | We will use the following code to determine whether a current template is set up correctly. | ||
+ | |||
+ | <code> | ||
+ | /** | ||
+ | * 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; | ||
+ | </code> | ||
+ | |} | ||
+ | {| | ||
+ | |style="padding: 0px 0px 15px 15px;"|'''7. Creating URL Redirection'''<br/> | ||
+ | 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.<br/>Redirection needs to be executed when switching the language is done by a user or together with changing the language. | ||
+ | |||
+ | <code> | ||
+ | /** | ||
+ | * 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; | ||
+ | </code> | ||
+ | |} | ||
+ | == == | ||
+ | {| | ||
+ | |style="padding: 0px 0px 15px 15px;"|'''''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.<br/>So let's make your business even more personal! | ||
+ | |} | ||
+ | {| | ||
+ | |style="padding: 0px 0px 30px 15px;"|''In the meantime, you are more than welcome to visit our [https://www.blog.modulesgarden.com/automatic-currency-and-language-setup-for-whmcs/ '''Blog'''] where you can also check out other interesting articles.'' | ||
+ | |} |
Revision as of 10:40, 9 February 2017
Geolocation Hook For WHMCS In A Nutshell
Geolocation Hook For WHMCS
When it comes to providing complex solutions to the business, ModulesGarden is always within your reach. This time we would like to share the idea of Geolocation Hook with you! |
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.
/** * 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. |
In the meantime, you are more than welcome to visit our Blog where you can also check out other interesting articles. |