Skip to content

Instantly share code, notes, and snippets.

@haroldkyle
Created November 29, 2013 05:35
Show Gist options
  • Save haroldkyle/7701984 to your computer and use it in GitHub Desktop.
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.
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