WooCommerce – How to Restrict Products by City (Location Restrictions)

In this post, we’ll show you how to restrict WooCommerce products by city. You’ll learn how to sell products to specific cities or ban other cities from purchasing these products on your WooCommerce store.

This can be really useful when you don’t ship your products to a specific city in a specific country, and you don’t want the customers to be able to place the order in your WooCommerce store.

Instead, you want to redirect them to a specific URL or show them an error message telling them the product isn’t available for their cities.

We’ll do it using the Woo Product Restrictions by Location plugin.

This plugin allows you to limit access to your products to specific cities.

You don’t need to program anything nor hire an experienced programmer because you can create restrictions by location for your WooCommerce products with a few clicks and using just some fields.

Once you install and activate the plugin, you need to follow these simple steps to restrict your WooCommerce products by city.

1- Select your restriction method (Add cities where you’ll restrict products)

Go to WooCommerce ➜ Settings ➜ Restrictions by Location.

Once there, you need to select the following settings:

  • In I want to restrict, you can select what you want to restrict, and you have at least three options:
    • Products and variations
    • Category and attribute pages
    • Coupons
  • In I want to restrict by, you need to select Custom list of locations.
  • After that, add the list of cities by entering the city Name and hitting Add location.
  • In What happens when the user location is unknown, you can:
    • Show all products
    • Hide all products
  • Once you select these options, hit Save changes.

2- Optional – Globally restrict all your WooCommerce products by city

After selecting the list of cities where your WooCommerce products will be restricted, you have the option to globally restrict all your WooCommerce products for a specific city. This means none of your products will be sold to people in the selected cities.

You need to move to the Products per location tab in Restrictions by location and select the following values:

  • In Products per location, you need to select the cities that can/can’t see your products.
  • In Sell in selected locations, select No to restrict the products on the selected locations.
  • In the What happens when a customer location is restricted section, you have the following sections:
    • Exclude product from the catalog listing
    • The product page will disappear completely
    • The product page should show the content from another page
    • Redirect product page to a specific URL
    • Show a specific message on the product page
    • Show a specific message on the checkout page
    • Remove the product from the cart and checkout
    • Remove the “Add to cart” button from the product page and the catalog
    • Hide the product price from the catalog and the product page
    • Hide the product reviews from the product page
    • Remove the product link from the navigation menus of your store

Note – In this example, we’ve selected the following options:

  • Remove add to cart
  • Hide product price

Once you select the necessary settings, hit Save changes.

3- Optional – Restrict specific products by city

If you don’t want to globally restrict your products by city, you can restrict individual products. This means some products will be available for the selected cities and some won’t.

For this, you need to open the product you’ll restrict.

Now move to the Product data ➜ General.

In Location restrictions select:

  • Available in selected locations: No
  • Optional – You can enter a URL to redirect the customer when the location is restricted in the Redirect to this URL when the location is restricted field.

Finally, Save the changes on your product and continue editing other products.

woocommerce restrict products by city

Let’s see the results

If you restrict all the products from your store, customers from the selected cities will see a message telling them there’s no allowed products for their city. Also, they will be able to view a dropdown where they can select their city.

Depending on what you select, this is what users could see when they open a specific product that is restricted for their city:

That’s really easy!

As you see, restricting WooCommerce products by city is really easy with the Woo Product Restrictions by Location plugin.