In this tutorial, we’ll show you how to restrict WooCommerce products by state or province. For example, if you sell products in the US, we’ll show you how to restrict products and show a state selector in the header. Of course, you can select any other country to restrict the products in its states.
However, WooCommerce doesn’t have that option, but we’ll do it using the Country Catalogs for WooCommerce plugin.
It allows you to apply country restrictions to your products, categories, variations, etc. to create country catalogs for your WooCommerce store. You can also show different product prices and descriptions for different countries.
Once installed and activated, follow these simple steps.
Step 1. Open the Global Settings
Go to WooCommerce > Advanced Country Restrictions > Open Global Settings.
Step 2. Select how you’ll restrict the products
- Restrict by: State
Important. The list of states will be from the “base country” defined in the WooCommerce settings. To change the base country, go to WooCommerce > Settings > General > Store Address > Country.
Step 3. Select the state restriction settings
- Geolocation method: Show country/state selector in the header
- Restriction method: Here we have three options
- a) Hide product from the catalog
- b) Show product in catalog, disable add to cart, show prices
- c) Show product in catalog, disable add to cart, hide prices
- For example, we’ll select the third option.
- Dropdown selector options: Select the states that you want to display in the list. Leave it empty to display the shipping countries from the WooCommerce settings.
- Dropdown selector: Select the default country or state you want to show in the selector in the header.
Step 4. Edit the product state restrictions
Once the global state restrictions are selected, you can open a product and select its state restrictions.
For example, if you open any product of your store, you need to go to Product data > Country restrictions.
- In Selected Countries, you’ll find the list of states of your base country. Let’s restrict the product for California.
- In Available in selected countries, you need to select No to restrict that product.
When customers visit the store and select the edited product, they will see a message indicating that the selected product is not available in their location.
The users need to select the state in the header dropdown, and the restrictions will be applied based on that.
Of course, if you selected Hide products from catalog in Restriction method (Step 3), the customers won’t see the products on the catalog.
In the Global Settings of the plugin, you can enable a popup that will appear the first time a user opens the website. This popup will show the different states you selected and will ask the user to choose one.
You can enable this popup going to Global Settings > Dropdown selector: Display a popup asking the user to select a country? And select Yes.
As you see, it’s really simple to edit your products’ state restrictions. You don’t need to use any codes; just edit some simple fields and you’ll be done.