Skip to content

Instantly share code, notes, and snippets.

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 woogists/9fb581b5fd3c5bd34e36031141e2b691 to your computer and use it in GitHub Desktop.
Save woogists/9fb581b5fd3c5bd34e36031141e2b691 to your computer and use it in GitHub Desktop.
[USPS Shipping Method] Exclude a country from receiving USPS rates
add_filter( 'woocommerce_package_rates', 'wcsupport_no_usps_us', 10, 2 );
function wcsupport_no_usps_us( $rates, $package ) {
if ( WC()->customer->shipping_country == 'US' ) {
foreach( $rates as $key => $rate ) {
if (strpos($key,'usps') !== false) {
unset( $rates[$key] );
}
}
}
return $rates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment