Created
November 29, 2013 05:35
-
-
Save haroldkyle/7701984 to your computer and use it in GitHub Desktop.
Removes unnecessary countries (and their states) from the woocommerce_params that Woocommerce JSON encodes on every Wordpress page.
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
add_filter('woocommerce_states',function($countries){ | |
// list the countries you actually want states for in this array | |
$countries_with_states = array( 'US','CA'); | |
foreach($countries as $country=>$states){ | |
if( !in_array($country, $countries_with_states) ){ | |
unset( $countries[$country] ); | |
} | |
} | |
return $countries; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment