<?php
/*
* Woocommerce Push UK & USA to the top of the country list
*/
add_filter('woocommerce_sort_countries', '__return_false');
add_filter( 'woocommerce_countries', 'change_country_order_in_checkout_form' );
function change_country_order_in_checkout_form($countries)
{
$uk = $countries['GB']; // Store the data for "UK key
unset($countries["GB"]); // Remove "UK entry from the array
$usa = $countries['US']; // Store the data for "US" key
unset($countries["US"]); // Remove "US" entry from the array
// Return "UK then US" first in the countries array
return array('GB' => $uk, 'US' => $usa ) + $countries;
}