Automatic Currency, Language And Template Setup For WHMCS – Updated

The recognition of our Geolocation Hook For WHMCS has been continuously growing among the global community of WHMCS users. Having this exhilarating trend in mind, we felt extremely tempted to breathe new life into the original Blog post dated March 2013, and show the current potential lying within this simple, yet undoubtedly powerful tool.

What we present below is the catalog of most essential maneuvers you may carry out thanks to our hook. To help you find your way through the particular features more easily, the article has been supplemented with the exact code lines and clear guidelines on how to adjust them.

Configure the rules of currency, language and template changes

Adjustment of the client area pages depending on your clients location has been simplified to the maximum possible level. Edit the code with the provided in the commented areas tips to achieve any configuration of currency, language and templates.

PHP

1

2

3

4

5

6

7

8

9

10

/**

* Define relations between countries and currencies.

* Enter the currency code for each country (codes used), use the below pattern, edit it or add new entries below:

*/

$countryToCurrency=array(

'default'=>'USD',

'US'=>'USD',

'GB'=>'GBP',

// NOTE: You can add more below

);

PHP

1

2

3

4

5

6

7

8

9

10

11

/**

* Define language rules by assigning a language to a single country.

* Use the below pattern (language name for country code) edit it and/or add new entries below:

*/

$countryToLanguage=array(

'default'=>'english',

'US'=>'english',

'DE'=>'german',

'NO'=>'norwegian',

// NOTE: You can add more below

);

PHP

1

2

3

4

5

6

7

8

9

10

/**

* Configure additional settings:

* Firstly assign a WHMCS template to each country used.

* Use the below pattern (template name for country code) edit it and/or add new entries below:

*/

$countryToTemplate=array(

'US'=>'six',

'default'=>'six',

// NOTE: You can add more below

);

PHP

1

2

3

4

5

6

7

8

9

10

11

12

/**

* Now, define the language for each WHMCS template used.

* Please note that a template available in WHMCS V7 is: 'six'.

* It is important to use a template that exists within your WHMCS system.

* Not Logged In Users

*/

$templateToLanguage=array(

'english'=>'six',

'german'=>'six',

'default'=>'six',

// NOTE: You can add more below

);

Select a template depending on a mobile device or a domain used

You may point a template that shall be called, following the device type used, a tablet or a mobile. In the very same way, point the domain names that your visitors are redirected from, to turn on a specific template for them. Uncomment the lines and provide required templates names.

PHP

1

2

3

4

5

6

7

8

9

/**

* You may define a mobile template per a mobile device: mobile and tablet types.

* Use the below pattern (template name for mobile device) and edit the entries.

* Comment out to disable the option.

*/

$mobileToTemplate=[

// 'mobile' => 'mobile_template',

// 'tablet' => 'tablet_template',

];

PHP

1

2

3

4

5

6

7

8

/**

* You may define templates per domain name. Enter a domain name and assign a template to each one of them.

* Uncomment the below examples to turn on.

*/

$domainToTemplate=[

//'www.example.mobi' => 'mobile_template',

//'www.example.com' => 'six',

];

Select adjustable pages of your client area

The hook offers huge flexibility when it comes to personalizing a whole or just a specific part of your client area. You are free to select the exact pages where the alterations should be performed.

PHP

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

/**

* Enter pages in your WHMCS which the hook will be active for.

* Add more pages at the bottom of the list, comment out single pages to disable the hook for them:

*/

$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

);

Disable the hook with ease

There might be cases when you do not wish the hook to alter the client area. You are given a wide range of possibilities to turn off the hook for specific IP addresses, IP pools or certain user agents – all is up to you!

PHP

1

2

3

4

5

6

7

8

9

/**

* Point single IP addresses. The hook will be turned off for these addresses.

* Uncomment the below list and edit the exemplary addresses, add more at the bottom of the list:

*/

$disabledForIPs=array(

// '91.192.166.22',

// '192.168.0.39',

// NOTE: You can uncomment or add more below

);

PHP

1

2

3

4

5

6

7

8

9

/**

* Point full IP pools. The hook will be turned off for the addresses in these pools.

* Uncomment the below list and edit the exemplary addresses, add more at the bottom of the list:

*/

$disabledForCidrIPs=array(

// '192.168.56.0/24',

// '192.168.0.39/24',

// NOTE: You can uncomment or add more below

);

PHP

1

2

3

4

5

6

7

8

9

10

11

12

13

/**

* Point user agents. The hook will be turned off for the enumerated here devices/browsers.

* Enter a short or a full user agent name like in the examples below.

* Uncomment the below list and edit the exemplary entries, add more at the bottom of the list:

In order to track your clients’ locations, either use the included in the package submodule, or add your own submodule.

PHP

1

2

3

4

5

6

/**

* Get the country using an external service, e.g. MaxMind GeoLite

* http://dev.maxmind.com/geoip/geolite

* NOTE: You can also create your own submodule, edit the below line in such case as only one submodule can work at a time.

*/

$submodule='GeoIP2';

If the article does not cover the configuration scheme you look for, it most likely can be found in our Wiki article. Apart from detailed instructions on how to upload and configure the tool, you will find there several visualizations of how the client area may be adapted with this neat, completely free of charge hook.

168 comments

Everything looks to be fine except the case of forced currency in links (&currency=*). If the customer clicks the button which has such a link it is redirected to cart.php and not to the product or even product group. On second click it works as it should but only after clicking it twice. Testing it several times before adding this comment with 4 browsers.
You have my email address for explicit details.

Hello Piotr
Are you sure that the downloadable archive is updated ? I did compared previous file and last one and there is no difference between them. This time I didn’t made any modifications (default currency/language) and just uploaded it on server and obviously the problem was still there.
I’d like to have it work at 100% as much as you do and this is the reason why I’m bothering.
PS: I use a new and different browser after each test to get ride of session or cookie which remembers data/values. You can message me directly on Tweeter, Skype or email.

Yes Gabiel, the file has been updated. Today we have verified this twice on our end (downloaded the module from the link provided in this blog article) and the problem you described was fixed, as stated before.
Please create a ticket https://www.modulesgarden.com/openticket and we will assist you, as we expect that the problem is caused by your environment and not by the hook file itself.

Nicolas, to be honest, we didn’t focus on making our hook as SEO friendly as most likely it should be. However we will take this into consideration. I am pretty sure that we are not yet finished with performing changes to the hook, so sooner or later an updated version will appear.

Hello,
this seems to be very helpfull! How complicated would it be to also force payment gateway depending on selected language (or GeoIP country)? I’d like to block PayPal payments for visitors coming from a certain country.

It won’t be that easy Vinko, because it will require direct template modification in the invoice template. Hook script would need to be called separately to assign the variables within your template. If you are interested, please contact our Development Department.

I think other web site owners should take this web site as an model – very clean and excellent style and design, in addition to the content. You are an expert in this area and I will definitely try the hook in my WHMCS!

That looks very interesting and very confusing, I personally have different domains. eg: .eu .co.uk .in and they redirect to my main website with the ?currency=1 and that configures my website’s prices.

Your way is by the country which is better than my way however they can change the currency by the flags on the new layout or by the cart .

I think this is one of the most popular hook it is on the market, I’ll get it immediately and I’m sure the support I receive to make the installation will be more expert in customer service on my system management customer. Cheers ModulesGarden!

I discovered your blog website on google and check a couple of of your early posts. Continue to keep up the really good operate. I just additional up your RSS feed to my MSN News Reader. Searching for forward to reading even more from you later on!

I am new to whmcs. I have downloaded the files and placed them in the includes/hooks folder as mentioned. However I do not know where and how I should configure the $country variable. Could you please provide a few more steps of instructions.

According to our quick tests you should have been redirected to domain.com/cart.php?gid=1&language=english . I have updated the hook file on our server which should help. Please download it once again and check whether this solved the problem.

This will not work as intended. Indeed, language won’t be changed, but neither the template. Do you want to make ‘language’ parameter invisible in URL when customer’s language is the same as default WHMCS language?

As i have seen until now, the allowed scripts page, is not working.
For example:
I will initially try to visit site.com/a.php
The result is a blank page!
But if I visit, site.com and then try to visit /a.php, the script works fine…

language and currency does not work,
I did not do any configuration, I just uploaded the file geolocation_hook.php, geoip.inc and GeoIP.dat.
always display default language and currency, try change my ip , but not work
Another configuration?
thank you

We have verified this on WHMCS 5.3.7 but we are unable to find a malfunction in our hook. We expect that the problem lays within your configuration but we are not sure about that. Could you please create a ticket and provide us with access details to your system? In this way our developer will help you solve the problem.

Ernesto, in this case we would need to access your environment and check it out because basing on last statement, it is difficult to guess whether we can call the hook or not. Feel free to create a ticket and one of our developers will check this for you.

I have the plugin working, but I noticed that it’s no longer possible to change currency by clicking on the flag/currency tab after it’s been set. So it does work, but changing currency is no longer an option after it gets assigned to the client. Is there a way to allow users to still change their currency?

Where I think this module would be great would be to integrate with MultiBrands and ResellerCenter. Think of it from EU VAT where you may want different Brand or Reseller for specific region/partners. Just my 2 cents.

It will be best if you open a ticket in that matter as we suggested in the response to your previous comment. Once you provide required access details, we will be able to eliminate the issue directly in your environment.

Yes, the problem related to SEO was successfully disposed of back in April 2016. To take advantage of the latest release of Geolocation Hook For WHMCS, simply download it from our website. Also, if you wish to keep tabs on the flow of its updates, be sure to have a careful look at the changelog.

On the 7.1 which is to remove the currency change from the template, apparently this does not appear out as lines of codes under the WHMCS v6 standard_cart. While the hook is added on 7.2 to prevent the changes, it might be good to just take this off from the client area cart as trying to click to change the currency does not looks to be working due to the use of this geolocation hooks.

Okay got it.. apparently the modern template was being reference as well from the standard_cart, removing the currency in the modern cart products.tpl did the trick. However, we do notice there’s 2 section of the code needs to be remove – one as outlined on the guides above and the other one just at the end of the same files.

Hi again Your last update had cause little bit something wrong js. When our customers get on Mobile, we just forward ?systpl=mobile with javascript on header, Now your systpl is not working this hook, Already we are tryin on

To successfully prevent template redirection please do as follows:
1) Remove code snippet: "&& !empty($systpl)", you should find it in line 167.
2) Comment out code snippets in lines 172, 174 and 191-233.

How can i set a currency if the IP is not recognised by the geoip ? For example it some times not recognizing ip addresses and changes the currency of the order to my local currency. However the problem is, if the product is priced as 5 usd it creates an invoice as 5 euro . I think the problem is about defining the ip and the country ip belongs to.

My aim is, where ever a visitor comes, if the ip is not recognized , force him to set currency predefined.

with php7 and whmcs 7.0.1 i have the problem, that we get the blank page, if customer come to site. The same like amit at 20 November 2015 here uper case. If we reload the page, all is very well. What can we do?

All your troubles most probably stem from the fact that the hook has not been yet adjusted to support WHMCS V7 and PHP 7. We are currently working on it, please expect the update to be available next week!

However, when I do all this, nothing is changed. No error, it simply does not change any thing. Do I need to have any other module with this too or it is not working because you are going to update the script?

You do not need any additional pieces of software to make the hook work, Hashmi. If you use WHMCS V7 please wait for the coming release as your issues are most likely related to the current lack of compatibility with V7.

Automatic Currency And Language hook not working on my site i am using WHMCS Bridge Version 3.8.3 . I try this hook on my site but this hook not working means it not changed currency based on geolocation i want if customer open this site in UAE then selected currency should be in AED and if customer open my site in other country then selected currency will be in $. please tell me the solution

It is difficult to identify the root cause of your troubles without looking into your system directly. Please join us in a ticket – use Confidential Data field to provide all access details in a highly secure manner.

We are happy to announce that the next generation of our
Geolocation Hook For WHMCS with WHMCS V7 & MaxMind GeoIP2 support and fully rewritten code has been released (v2.0.0). We have also created a documentation available on our Wiki. Enjoy!

Thank you for creating it a newer version! It doesn’t seem to work on my end though, and I have a question.
I want to use only “country to language”! Is it possible to change the language on the first visit without adding “?language=…”?

If I understand your question correctly, setting up a desired language as a default one should do the job. This is the section you need to adjust: $countryToLanguage = array(
'default' => 'english',
'US' => 'english',
'DE' => 'german',
'NO' => 'norwegian'
// NOTE: You can add more below
);

If the above mentioned suggestion does not resolve your doubts, I would like to kindly ask you to provide us with more detailed explanation via ticket.

We are eager to provide customers with precise information on our products so we will surely consider creating a video presentation of Geolocation Hook For WHMCS. For now, you are more than welcome to explore our Wiki documentation that will guide you through the operation of the hook step by step!

When it’s in active state WHMCS started showing warning “A Certificate Authority verified SSL certificate was not detected on domainname. This will prevent some features, such as OpenID Connect, from functioning. This may also affect your ability to receive PCI or other accreditation.”

If I disable the hook then warning disappear and OpenID used to function properly.

It might be difficult to find the exact reason behind such irregularity without accessing your environment. The best you can do is reach out to our support specialists directly and let them check the issue right within your system. No worries, all sensitive data are perfectly safe when passed through the Confidential Data box available on the ticket’s submitting page.

There is a problem with facebook share. When you are trying to share a link on facebook, it doesn’t parse anything simply because it uses the redirection method.
I have tried debugging the link in facebook debugger, but the problem is still there.

Please note however, that our module makes redirections by default and in principle this part should not be tampered with. If you require further assistance on how to work around this issue, just contact our Support Team and they will do their best to come up with a solution.

Hello,
After following the instructions in your blog we find that the currencies for other countries setup switches for USA, Germany and United Kingdom but does not work for Nigeria. Could you please help?

all the explanation you provide for this is only about the hook file i also see other folder in the zip i downloaded but there is no explanation where i can place it i also follow the explanation above and the result that my website stop working completely and the code i copy and past just same as you give above and it give me error and it become red color . so is there easy way to make this more easy for us ? i am just wandering for something why you just not make this ready for people to upload you can just place the code that you write pages about it in the files of the program and make it more easy for people to just upload in the folder than it will work . i feel like i need to study coding so i can use this lol its like you are giving us coding lesson not only program for use . anyway is there way for me to use this ? i want only to change language for countries so . i do not know what to do and as i said i copy the code you give above and it make my website stop working completely . code error . thanks

Hi Salah! Feel invited to study the Geolocation Hook For WHMCS documentation which will get you through the whole process step by step. We are positive it will provide you with all the answers you are looking for. If not, do not hesitate to contact our Support Team for more detailed explanation.

There are at least several possible causes behind this sort of an error, and without a deeper insight it is rather difficult to identify the right one. Please join our support specialists in a ticket so they can have a closer look at the issue.

Hi Ramiz,
We have not detected any faults in Geolocation Hook For WHMCS during the internal WHMCS V7.6 compatibility check. Please discuss this further with our experts at the Support Team, they will help you remove all problems affecting the hook’s operation.