Block the Delivery by city in WooCommerce.

Some time ago I’ve wrote on the limitation of US states in WooCommerce. However, a similar task may occur not only with the states, but also with individual counties or cities – it a matter of American administrative units.

In addition to the states, the US has the incorporated/unincorporated territory (such as Puerto Rico or the US Virgin Islands). Despite the fact that the action of the US Constitution on these islands is limited or has its own Constitution, US banks and delivery services work the same, as in the US states.

For store owner to WooCommerce which means that sometimes you may need to limit the acceptance of payments and sending orders for such territory.
Earlier, I wrote on the blog, how to exclude states for Woocommerce, and now show how you can exclude certain city. Just paste the code below to your theme’s functions.php:

This example make limit for Sarasota County, North Point, Venice and Longboat Key.

Incidentally, this solution can be used not only for the US but also for any other country. And not only for the city but also for all the other fields (such as an index or address).
Here is an example of how to restrict delivery in address field (for example, you do not want to send the products if customer used the PO Box):