In this tutorial, we’ll show you how to restrict or hide WooCommerce products by zip code range.
There are many cases where you might not want to sell in certain areas. For example:
- Your supplier doesn’t ship to specific regions.
- Delivery costs are too high in some zip code ranges.
- Certain products like alcohol, tobacco, CBD, frozen foods, or oversized furniture can’t be delivered everywhere.
- You only serve local delivery zones (e.g. within 100 miles of your warehouse).
- Some products are restricted by legal or licensing rules in specific zip codes.
Instead of manually blocking every zip code one by one, you can use a plugin to ban products for an entire range of postal codes. For example, you can block all customers with shipping zip codes between 90210 and 90299.
This guide will walk you step by step on how to hide WooCommerce products by postal code range using the WooCommerce Product Restrictions by Location plugin.
You can download the plugin here:
Download WooCommerce Product Restrictions by Store Location Plugin - or - Read more
Step 1. Select the global settings to hide products by zip code
First, you need to choose what you want to restrict. In this example, we’ll restrict WooCommerce products and their variations, but keep in mind that you can also restrict categories, attributes, or discount coupons if needed.
Next, you need to decide how the restriction will be applied. In this case, we’ll block products based on the customer’s zip code.
To do this:
- Go to WooCommerce > Settings > Restrictions by location.
- Tick the Products and variations checkbox.
- In I want to restrict by, select Zip code.
- Click on Save changes.
Step 2. Hide WooCommerce products by zip code range
Now you need to decide whether you want to block all products and variations for a specific zip code range, or only selected products and variations. Below are the different options you can use to set this up.
Option 1 – Hide all products and variations by range of zip codes
This setting will globally hide all products and their variations, so they won’t be displayed in your store whenever a visitor enters a zip code that falls within the restricted range.
To do this:
- Go to WooCommerce > Settings > Restrictions by location > Products per location in the admin dashboard.
- In Products per location, add the range of zip codes for which you want to hide your WooCommerce products. For example, you can enter
90210 > 90299
. - Sell in selected locations: No
- What happens when a customer location is restricted: You have some options:
- Exclude from catalog listing
- The product page should disappear completely
- The product page should show the contents from another page
- Redirect product page to URL
- Show message in the product page
- Show message in the checkout page
- Remove product from the cart and checkout
- Remove add to cart
- Hide product price
- Hide product reviews
- Remove product link from menus
- Click on Save changes.
Important: This setting applies to all of your products. Customers from the selected zip codes will not be able to purchase any products from your store.
Option 2 – Hide specific products from zip code range
If you don’t want to block all products from being sold in the selected zip code range, but instead prefer to restrict only certain individual products, you can do so by editing those specific products directly.
To do this:
- Go to Products > All Products in the admin dashboard.
- Open the product you want to edit.
- Go to Product data > General > Location restrictions.
- Zip codes: Add the zip code range; for example, you can enter 90210 > 90299.
- Available in selected locations: No.
- Click on Update the product to save the changes.
Note. If your products are variable, all variations will be hidden from the selected zip code range.
Option 3 – Hide specific variations by zip code range
If you don’t want to hide entire products, but only certain variations of your variable products (for example, hiding specific sizes or colors), you can easily do that as well.
To do this:
- Go to Products > All Products in the admin dashboard.
- Open the product you want to edit.
- Go to Product data > Variations.
- Open a specific variation.
- Move to the Location restrictions area.
- Zip codes: Add the zip code range; for example, you can enter 90210 > 90299.
- Available in selected locations: No.
- Click on Update the product to save the changes.
For example, if the variation you are hiding includes the attributes XS and Yellow, those options will be disabled in the store for customers within the restricted zip code range. This means:
- If a customer selects XS, the Yellow option will no longer be available.
- If they select Yellow, the XS option will be unavailable.
In short, the hidden variation cannot be purchased or combined by customers whose zip code matches the restricted range.
Option 4 – Hide all variations with specific attributes by zip code range
Sometimes you don’t want to block entire products, but only certain variations that match specific attributes. For example, maybe you can ship a T-shirt in most colors, but the Yellow XS variation isn’t available in some regions. With this option, you can hide any variation that contains the attributes you select, and it will only be hidden for customers whose zip code falls within the restricted range.
To do this:
- Go to WooCommerce > Settings > Restrictions by location > Variations per location in the admin dashboard.
- You can add different groups of rules, so click on Add new to create a new rules group.
- Select location: Enter the zip codes range; for example, enter 90210 > 90299.
- Select attributes: All the variations containing the attributes selected in this field will be hidden for the selected range of zip codes.
- Sell product variations in the selected locations: No.
- Click on Save changes.
Step 3. Test your location restrictions
To make sure your restrictions work correctly, you can enable the option to display a popup asking customers and visitors to enter their zip code. In this example, we’ll test the setting that globally hides all products from the catalog.
When a customer enters a zip code that falls within the restricted range, the affected products and/or variations will not be available for purchase.
Customers and visitors can update their location at any time using the zip code field located in the navigation menu.
If a customer enters a zip code that is allowed, they will be able to see and purchase all products and variations normally.
Restricting WooCommerce products by zip code range gives you full control over where your products can and cannot be sold. Whether you need to block all products, restrict specific items, or hide only certain variations and attributes, the WooCommerce Product Restrictions by Location plugin makes the process simple and flexible.
This is especially useful if you deal with shipping limitations, legal restrictions, or region-based delivery zones. Instead of manually managing each order or customer, you can set clear rules once and let your store handle the rest automatically.
Start applying location-based restrictions today to save time, stay compliant with regulations, and offer your customers a more reliable and localized shopping experience.
You can download the plugin here:
Download WooCommerce Product Restrictions by Store Location Plugin - or - Read more