Jump to content

Change the default country


gcphost

Recommended Posts

Hi

 

How do you change the default country selected on the users profile/order form?

 

I find many users are marked as fraud because they didnt bother to change their country - if it wasnt selected as USA by default - this would not be a problem

 

I looked at the code

<td>{if $loggedin}{$clientsdetails.country}{else}{$clientcountrydropdown}{/if}</td>

 

Is there a place to edit $clientcountrydropdown? I did not yet look as this thing is encoded.

 

 

Thanks.

Link to comment
Share on other sites

Hi

 

Thats great but it does not allow for "no" selection. I dont want any default at all - blank - making it 100% required that the user select it.

 

I see about 10% of all orders getting picked with the default country - on accident - as the rest of the info is proper.

Link to comment
Share on other sites

Basic idea - copy/paste the html and over-right the variable generated field (as that cant be edited, boo)

 

Works well now, would recommend not selecting a default country - or making it an option - it increases chance of fraud having it auto-selected

Link to comment
Share on other sites

There is a way to do it

open includes/countries.php and add this line to the top within the array

""=>"Select Country",

eg..

<?php
$countries = array(
""=>"Select Country",
"AF"=>"Afghanistan",
"AX"=>"Aland Islands",
"AL"=>"Albania",
"DZ"=>"Algeria",

<<<SNIP>>>

Go to admin->setup->general settings->localisation and select "Select Country" as the default.

Now create a file in your includes hooks directory called "country_validation.php" and put this code within it

<?php

if (!defined("WHMCS")) die("This file cannot be accessed directly");

function check_country($vars) {
   global $errormessage,$_LANG;
   if ($vars["country"] == "Select Country" || $vars["country"] == "") { $errormessage.="<li>".$_LANG['clientareaerrorcountry']; }
}

add_hook("ClientDetailsValidation",1,"check_country","");

?>

Link to comment
Share on other sites

In general, 90% of our clients are from two specific countries, and one region. These are:

 

  • The UK
  • The US
  • Europe

 

One thing we have done since first using WHMCS, (and your post reminded me of it) is to trim down the Countries list to something more meaningful.

 

As a user, I hate having to scroll through endless lists to just find the item I want, and I feel certain our clients do as well.

WHMCS simple solution

You can simply trim the countries list (/includes/countries.php) by deleting countries you don’t need from the countries.php file(to be honest, there were many I have never heard of).

As mentioned, the file is in the /includes folder.

 

Delete any countries you want, keeping the lines clean.

 

Just remember that the last entry does not have a comma after it and each entry line ends with a semi-colon ; (as its php!)

 

That helps a lot, but I also wanted to put our most common country (the UK) first.

 

Now the problem here is that every time the countries.php file is called to deliver its content, it sorts itself.

Thats good for most, but not for our requirement when we want to make sure a certain entry appears first.

 

One way to stop this and make sure the entry you want is at the top is to simply comment out the penultimate line:

 

asort($countries);

 

No need to delete it, just comment it out with a couple of slashes like this:

 

//asort($countries);

 

Now, the list is served up in the order of entries in the file without sorting.

This means you can promote the default value to the top of the list :D

 

The way Sparky has done it is far better, and addresses a slightly different scenario, but for a very simple and easy modification, editing the countries.php file is quick and easy.

 

As always, backup your files first!

 

Trevor

Link to comment
Share on other sites

True... you can edit the countries.php file to remove the ones that you don't want... but

what if you happen to get a client that is not within the country list that you have available and when they place an order the fraud module, maxmind in my case will mark the order as fraud because the potential and legit client can not pass the fraud test because he/she can't select their country.

 

Sometimes altering a simple thing can have consequenses somewhere else.

I don't know if anyone else remembers but the "Select Country" line was in an early V3 of whmcs... not sure why it was removed.

Link to comment
Share on other sites

You are correct in saying what you do about clients in countries that may be deleted.

 

However, for our purposes we would probably flag a lot of countries as fraudulent orders ourselves, even if MaxMind doesn’t!

 

As I mentioned, there are a whole range of countries I have never even heard of :!:

 

Trevor

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated