Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Last active December 22, 2023 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiR-DanieL/af36d7fecfbcc219aabe5a3537dd58b5 to your computer and use it in GitHub Desktop.
Save SiR-DanieL/af36d7fecfbcc219aabe5a3537dd58b5 to your computer and use it in GitHub Desktop.
Sell in Specific States/Provinces/Regions with WooCommerce
<?php
/**
* @template Sell to Specific States/Provinces/Regions with WooCommerce
* @author Nicola Mustone
* @author_url https://nicolamustone.blog/2014/12/08/sell-in-specific-states-with-woocommerce/
* @tested-up-to WooCommerce 8.4.X
*/
function wc_sell_only_states( $states ) {
$states['US'] = array(
'CA' => __( 'California', 'woocommerce' ),
);
return $states;
}
add_filter( 'woocommerce_states', 'wc_sell_only_states' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment