Skip to content

Instantly share code, notes, and snippets.

@WooForce
Last active March 31, 2016 12:02
Show Gist options
  • Save WooForce/861a0f5f33f63f4b0ba9 to your computer and use it in GitHub Desktop.
Save WooForce/861a0f5f33f63f4b0ba9 to your computer and use it in GitHub Desktop.
WooCommerce: Restrict shipping services for particular zip codes.
// Fedex Block Services for particular Zip Codes.
// Unset the shipping options of shipping method.
// You can find the shipping service codes by doing inspect element using
// developer tools of chrome. Code for each shipping service can be obtained by
// checking 'value' of shipping option.
add_filter('woocommerce_package_rates', 'wf_remove_shipping_options_for_particular_zip_codes', 10, 2);
function wf_remove_shipping_options_for_particular_zip_codes($rates, $package)
{
global $woocommerce;
$excluded_zip_array = array(
'93999'
);
if (in_array($woocommerce->customer->get_shipping_postcode() , $excluded_zip_array)) {
unset($rates['wf_fedex_woocommerce_shipping:FEDEX_GROUND']);
}
return $rates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment