Skip to content

Instantly share code, notes, and snippets.

@munts
Created August 26, 2020 19:10
Show Gist options
  • Save munts/336cd6998a19e0818c13ee12d35bdec6 to your computer and use it in GitHub Desktop.
Save munts/336cd6998a19e0818c13ee12d35bdec6 to your computer and use it in GitHub Desktop.
Set WooCommerce base location so that local city/county taxes are charged if local pickup is selected as the shipping option.
add_filter( 'woocommerce_countries_base_postcode', 'force_local_pickup_tax_location_zip' );
function force_local_pickup_tax_location_zip(){
return '90210';
}
add_filter( 'woocommerce_countries_base_city', 'force_local_pickup_tax_location_city' );
function force_local_pickup_tax_location_city(){
return 'Beverly Hills';
}
@munts
Copy link
Author

munts commented Aug 26, 2020

WooCommerce Documentation uses deprecated php: https://docs.woocommerce.com/document/local-pickup/
'create_function' is deprecated since 7.2.0
add_filter( 'woocommerce_countries_base_postcode', create_function( '', 'return "80903";' ) );
add_filter( 'woocommerce_countries_base_city', create_function( '', 'return "COLORADO SPRINGS";' ) );

From php.net: "Warning This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment