Last active
March 4, 2019 21:15
-
-
Save michaelaguiar/440869696babcb0b70f07e291949e6e6 to your computer and use it in GitHub Desktop.
Set
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
<?php | |
/** | |
* Sell only in specific states | |
*/ | |
add_filter( 'woocommerce_states', 'wc_sell_only_states' ); | |
function wc_sell_only_states( $states ) | |
{ | |
$states['US'] = [ | |
'AL' => __( 'Alabama', 'woocommerce' ), | |
'AK' => __( 'Alaska', 'woocommerce' ), | |
'AZ' => __( 'Arizona', 'woocommerce' ), | |
'AR' => __( 'Arkansas', 'woocommerce' ), | |
'CA' => __( 'California', 'woocommerce' ), | |
'CO' => __( 'Colorado', 'woocommerce' ), | |
'CT' => __( 'Connecticut', 'woocommerce' ), | |
'DE' => __( 'Delaware', 'woocommerce' ), | |
'DC' => __( 'District Of Columbia', 'woocommerce' ), | |
'FL' => __( 'Florida', 'woocommerce' ), | |
'GA' => _x( 'Georgia', 'US state of Georgia', 'woocommerce' ), | |
'HI' => __( 'Hawaii', 'woocommerce' ), | |
'ID' => __( 'Idaho', 'woocommerce' ), | |
'IL' => __( 'Illinois', 'woocommerce' ), | |
'IN' => __( 'Indiana', 'woocommerce' ), | |
'IA' => __( 'Iowa', 'woocommerce' ), | |
'KS' => __( 'Kansas', 'woocommerce' ), | |
'KY' => __( 'Kentucky', 'woocommerce' ), | |
'LA' => __( 'Louisiana', 'woocommerce' ), | |
'ME' => __( 'Maine', 'woocommerce' ), | |
'MD' => __( 'Maryland', 'woocommerce' ), | |
'MA' => __( 'Massachusetts', 'woocommerce' ), | |
'MI' => __( 'Michigan', 'woocommerce' ), | |
'MN' => __( 'Minnesota', 'woocommerce' ), | |
'MS' => __( 'Mississippi', 'woocommerce' ), | |
'MO' => __( 'Missouri', 'woocommerce' ), | |
'MT' => __( 'Montana', 'woocommerce' ), | |
'NE' => __( 'Nebraska', 'woocommerce' ), | |
'NV' => __( 'Nevada', 'woocommerce' ), | |
'NH' => __( 'New Hampshire', 'woocommerce' ), | |
'NJ' => __( 'New Jersey', 'woocommerce' ), | |
'NM' => __( 'New Mexico', 'woocommerce' ), | |
'NY' => __( 'New York', 'woocommerce' ), | |
'NC' => __( 'North Carolina', 'woocommerce' ), | |
'ND' => __( 'North Dakota', 'woocommerce' ), | |
'OH' => __( 'Ohio', 'woocommerce' ), | |
'OK' => __( 'Oklahoma', 'woocommerce' ), | |
'OR' => __( 'Oregon', 'woocommerce' ), | |
'PA' => __( 'Pennsylvania', 'woocommerce' ), | |
'RI' => __( 'Rhode Island', 'woocommerce' ), | |
'SC' => __( 'South Carolina', 'woocommerce' ), | |
'SD' => __( 'South Dakota', 'woocommerce' ), | |
'TN' => __( 'Tennessee', 'woocommerce' ), | |
'TX' => __( 'Texas', 'woocommerce' ), | |
'UT' => __( 'Utah', 'woocommerce' ), | |
'VT' => __( 'Vermont', 'woocommerce' ), | |
'VA' => __( 'Virginia', 'woocommerce' ), | |
'WA' => __( 'Washington', 'woocommerce' ), | |
'WV' => __( 'West Virginia', 'woocommerce' ), | |
'WI' => __( 'Wisconsin', 'woocommerce' ), | |
'WY' => __( 'Wyoming', 'woocommerce' ), | |
'AA' => __( 'Armed Forces (AA)', 'woocommerce' ), | |
'AE' => __( 'Armed Forces (AE)', 'woocommerce' ), | |
'AP' => __( 'Armed Forces (AP)', 'woocommerce' ), | |
'AS' => __( 'American Samoa', 'woocommerce' ), | |
'GU' => __( 'Guam', 'woocommerce' ), | |
'MP' => __( 'Northern Mariana Islands', 'woocommerce' ), | |
'PR' => __( 'Puerto Rico', 'woocommerce' ), | |
'UM' => __( 'US Minor Outlying Islands', 'woocommerce' ), | |
'VI' => __( 'US Virgin Islands', 'woocommerce' ), | |
); | |
return $states; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment