Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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
You can’t perform that action at this time.