WooCommerce – How to Restrict Products by Zip Code

Hello, friends. In this tutorial, we will show you how to restrict WooCommerce products based on customer zip code. This is very useful to create custom location restrictions and avoid sending products to specific zip codes.

The best thing is that you can restrict specific zip codes from accessing your store globally, or do it on each product in your store to restrict only some products.

You need to install and activate the WooCommerce Product Restrictions by Zip Code plugin.

Once you install the plugin, follow the steps in the sections below to restrict individual products, product categories, or all products by zip code.

1- Select the “zip codes” restriction method

The first thing we need to do is to define the location constraint method we will use.

To do this, we need to go to WooCommerce > Settings > Restrictions by location > General.

Once there, we need to select the zip code restriction method by using these values:

  • I want to restrict: You can select what you want to restrict, and you have the following options:
    • Products and variations
    • Category and attribute pages
    • Coupons
  • I want to restrict by: You need to select Zip code.
  • What happens when the user location is unknown: You can show all products or hide all products from the catalog.
  • Once you select your settings, hit Save changes.

woocommerce restrict products by zip code

2- Optional – Restrict all your WooCommerce products globally by location

Once you’ve selected the global settings to restrict your products by zip code, you can restrict all the products from your store for selected zip codes.

For this, you need to move to the Products per location tab, and select the following values:

  • In Products per Location, you need to enter zip codes separated with commas or add each zip code on a line.
  • Sell in selected locations: No
  • What happens when a customer location is restricted: Here you have several options:
    • 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

In this example, we’ll select the Redirect product page to a specific URL, and we need to enter the URL to which we’ll redirect our customers, which is our homepage.

Once you select the options, hit Save changes.

woocommerce restrict products by zip code

3- Optional – Restrict specific products by zip code

If you don’t want to restrict your products by zip code globally, you can restrict them individually, editing each product. This is really useful if some products will be available for the selected zip codes.

  1. Go to Products > All Products.
  2. Open the product you want to edit.
  3. Go to Product Data > General > Location restrictions.
  4. Zip codes: Enter the restricted zip codes in this field.
  5. Available in selected locations: No
  6. Redirect to this URL when the location is restricted: Enter a URL to redirect customers to it.

woocommerce restrict products by zip code

4- Optional – Restrict entire categories by zip code

If you don’t want to edit your products one by one to restrict them by zip code, you can create a category and restrict it by zip code.

Here’s a tutorial where you can learn how to restrict entire categories by zip code.

Restricting your WooCommerce products by zip code is really simple!

As you see, the WooCommerce Product Restrictions by Zip Code plugin gives you the easiest way to restrict your WooCommerce products by zip code.