Created
July 15, 2021 12:12
-
-
Save jorpdesigns/ed81df0190f8d48619ce99b275959e57 to your computer and use it in GitHub Desktop.
Snippet to reorder countries in dropdown on WooCommerce checkout form
This file contains hidden or 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 | |
// DISABLE WOOCOMMERCE SORTING | |
add_filter( 'woocommerce_sort_countries', '__return_false' ); | |
add_filter( 'woocommerce_countries', 'wc_custom_countries_order', 10, 1 ); | |
function wc_custom_countries_order( $countries ) { | |
// Replace with iso code of country AND country name (example: US | United States or GB | United Kingdom (UK) | |
$countries = ['GB' => 'United Kingdom'] + ['US' => 'United States'] + ['CA' => 'Canada'] + $countries; | |
return $countries; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment