Skip to content

Instantly share code, notes, and snippets.

@growdev
Created May 13, 2015 15:05
Show Gist options
  • Save growdev/af4844f0b58a741f245b to your computer and use it in GitHub Desktop.
Save growdev/af4844f0b58a741f245b to your computer and use it in GitHub Desktop.
Remove USA non-contiguous 48 states from WooCommerce
<?php
/*
* Plugin Name: Grow Development Remove States
* Plugin URI: http://growdevelopment.com/
* Description: This plugin removes states, provinces and armed forces locations outside contiguous 48 states.
* Version: 1.0.0
* Author: Grow Development
* Author URI: http://growdevelopment.com/
*
*/
/**
* Only ship to the contiguous 48 states
*/
add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
function custom_woocommerce_states( $states ) {
unset($states['US']['AK']);
unset($states['US']['HI']);
unset($states['US']['AA']);
unset($states['US']['AE']);
unset($states['US']['AP']);
unset($states['US']['AS']);
unset($states['US']['GU']);
unset($states['US']['MP']);
unset($states['US']['PR']);
unset($states['US']['UM']);
unset($states['US']['VI']);
return $states;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment