Created
May 13, 2019 10:16
-
-
Save paullacey78/8d55c67ccee1ab5c39f328b863dc4b2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment