One question I get a lot is “How can I restrict shipping when X”, where X can be anything like when there is a product is in the cart or for specific countries/states. There are a couple ways on how you can restrict shipping to those different conditions. Here I will show two options;
1) Prevent shipping rates from showing up,
2) Add shipping validation rules

Prevent Shipping Rates From Showing Up

Restrict shipping with zip codes / states / countries

If you want to restrict shipping to certain geographical locations, or only want to ship to certain areas, I can recommend to use the WooCommerce Advanced Shipping – Shipping Zones extension. With that extension, you can setup a shipping zone of zip codes, states or counties, which you can then use as a ‘shipping zone’ condition.

Setup a condition like the following in order to restric the current shipping rate to only the selected shipping zone. This way there is no way the user can order without being inside the shipping zone.


The other way around, restricting shipping to NOT the East coast of the US. With this way you can exclude the East coast from that shipping rate.


Restrict shipping of specific products

If you have some products that cannot be shipped, you can make sure the shipping rate doesn’t show up in a very similar way as above. With the following condition I will prevent flying ninja from shipping with the current shipping rate (remember to add the same condition to other rates if you want to prevent shipping at all).


Restrict products to a specific area

It could also be that you only want to prevent shipping of a specific product to a specific area. In that case you can combine the condition above with the shipping zone condition (or other ‘country’, ‘state’, ‘zipcode’ etc conditions) to prevent a specific products from shipping to that area.

Message showing up

When you’ve setup your shipping rates and a customer wants to checkout from a location that doesn’t allow shipping from the configuration you’ve setup, they will get a “No shipping available” message. This message is from WooCommerce Core and can be changed as read here: How to Change the “No Shipping methods available” Message.

Setting Up Shipping Validation Rules

Another way of restricting/preventing shipping is by setting up shipping validation rules. A shipping validation rule is fired when someone actually presses the ‘Order now’ button when they’ve entered all their data. It is exactly the same type of message when you want to checkout, and didn’t enter your name for example. You will get a notice saying ‘ Name is required. Please fill in […]’.

I’ve written a blog post about how to setup shipping validation rules on the blog; Setting Up Shipping Validation Rules in WooCommerce.

(A shipping validation rule looks like this)