Hide shipping methods based on destination zip code

The code snippet facilitates you to hide specific shipping method(s) depending on destination zip code of an order.

Add the following code to your functions.php or anywhere relevant.

In the above code:

– $available_shipping_methods contains all the available shipping methods for the carrier.

$postcode contains postcode of destination.

$hide_methods array contains the postcodes with corresponding services to be hidden.

If $postcode matches with the postcode in $hide_methods, then assign services of corresponding postcode to_hide, unset $available_shipping_methods and return it.

Scroll to Top