Skip to content

Instantly share code, notes, and snippets.

@WooForce
Created August 16, 2016 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save WooForce/8404eacd63882b5efad32ce4e3ad2370 to your computer and use it in GitHub Desktop.
Save WooForce/8404eacd63882b5efad32ce4e3ad2370 to your computer and use it in GitHub Desktop.
Adjusting puerto rico as state
function wf_remove_puerto_rico_country( $country ) {
if(array_key_exists('PR', $country))
{
unset($country['PR']);
}
return $country;
}
add_filter( 'woocommerce_countries', 'wf_remove_puerto_rico_country', 10, 1 );
function wf_add_puerto_to_us_states( $states ) {
$us_states = $states['US'];
if(!array_key_exists('PR', $us_states))
{
$us_states['PR'] = 'Puerto Rico';
}
asort($us_states);
$states['US'] = $us_states;
return $states;
}
add_filter( 'woocommerce_states', 'wf_add_puerto_to_us_states' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment