WooCommerce – How to Restrict Variations by Zip Code

In this tutorial, we will show you how to restrict WooCommerce variations by zip code.

With this restriction, you will be able to sell specific variations to specific zip codes, and hide them for other zip codes. This allows you to better segment your sales.

We will do this using the WooCommerce Product Restrictions by Zip Code plugin, which allows you to create restrictions for your products, categories, variations, and coupons by city, zip code, store location, province, state, etc.

After installing and activating the plugin, follow the steps below to restrict WooCommerce variations by zip code.

Set up the variations by zip code restriction method

Since WooCommerce Product Restrictions by Zip Code allows you to restrict products, variations, categories and coupons; and since it allows you to restrict content using different restriction methods such as city, store location, etc., you need to set up the zip code restriction method on the global settings of the plugin.

Go to WooCommerce > Settings > Restrictions by location and select the following values:

  • I want to restrict: Products and variations
  • I want to restrict by: Zip code
  • What happens when the user location is unknown: You can show or hide all products
  • Once you’re done, hit Save changes.

woocommerce restrict variations by zip code

Option 1 – Restrict WooCommerce variations by zipcode globally

The first thing we want to show you is how to display your variations containing specific attributes to specific zip codes, and hide them from all other zip codes. This can also be applied the other way around, i.e. hide for specific zip codes and show for all other zip codes.

For this, you need to go to the Variations per location tab in the global settings of the plugin.

Once ther, you need to add a rule that states that all the product variations containing the selected attributes will be shown or hidden for specific zip codes:

  • Select location: Here you need to enter the zip codes separated with commas or add a zip code in each line.
  • Select attributes: Add the attributes the variations must have.
  • Sell product variations in the selected locations:
    • YES means that all variations containing the selected attributes will be visible for the selected zip codes only.
    • NO means that variations with the selected attributes will be visible for all zip codes, except for the selected zip codes.
  • In this case, we will select NO because we want our variations with the selected attributes to be visible to all the zip codes, except for the ones we have entered in Select location.
  • Once you select the values, hit Save changes.

woocommerce restrict variations by zip code

The plugin will show a popup asking the user to enter their zip codes when they visit the site:

As you can see in the screenshot below, the variations with the black and large attributes were hidden for the zip code we have entered. Therefore, we will only see the variations that are not restricted.

woocommerce restrict variations by zip code

On the contrary, if we enter another zip code, we will see that the selected variation is visible, but the other variations are hidden. This allows you to create product catalogs by zip code easily.

woocommerce restrict variations by zip code

Option 2 – Restrict WooCommerce variations by zip code individually

If you do not want to restrict variations globally, you can also open a specific variable product, and restrict specific variations of that variable product.

For example, we are going to hide the variation with the blue and large attributes for specific zip codes. Just open the options for the variation you want to hide, and select the following values.

  • Zip codes: Add the zip codes here.
  • Available in selected locations: No
  • Scroll down and hit Save changes to apply the changes to the variations.
  • Hit Update to save the changes on the product.

woocommerce restrict variations by zip code

Once we visit our store as a normal user, we will see a popup asking us to enter our zip code.

In this case, we will enter one of the blocked zip codes.

woocommerce restrict variations by zip code

As you see, we can select the Blue attribute, but we can’t select the Large attribute.

The same will happen when we select the Large attribute, i.e. we won’t be able to select the Blue attribute.

woocommerce restrict variations by zip code

As you see, restricting your product variations by zip code is really simple with the WooCommerce Product Restrictions by Zip Code plugin. You can create different catalogs for different zip codes easily.