How to change countries order on VirtueMart

Supposing our company is based in the UK and  the United States are our biggest customers, let’s see how we can adjust “country” settings, for a faster country select in that big list.

countryselect

      As we can see, the customer must spend some time in order to select his country. Starting from our scenario, we need UK and US in the top of the countries list. For that we need to adjust  administrator/components/com_virtuemart/helpers/shopfunctions.php file,

before the below line which is at the end of the renderCountryList function

return JHTML::_ (‘select.genericlist’, $countries_list, $idA, $attrs, $id, $name, $countryId);

by adding following code
//////////////////////////////////////
//print_r($countries_list);exit;
$tarr=array();
foreach($countries_list as $c)//first countries
{
if($c->virtuemart_country_id=='223' || $c->virtuemart_country_id=='222' || $c->virtuemart_country_id=='')
{
$tarr[]=$c;
}
}
foreach($countries_list as $c)//rest of the countries
{
if($c->virtuemart_country_id!='223' && $c->virtuemart_country_id!='222' && $c->virtuemart_country_id!='')
{
$tarr[]=$c;
}
}
$countries_list=$tarr;
//////////////////////////////////////

This will add United Kingdom(222) and United States (223) at top of the list.

countries2

That’s all, hope this trick will be helpful for you!

Comments

comments