Created
March 9, 2018 16:39
-
-
Save woogists/9fb581b5fd3c5bd34e36031141e2b691 to your computer and use it in GitHub Desktop.
[USPS Shipping Method] Exclude a country from receiving USPS rates
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
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