In this tutorial, we will show you how to restrict WooCommerce product variations by country.
Restricting WooCommerce variations per country can be beneficial for various reasons. Here are some:
- Legal compliance: Some products may not be legal or compliant with regulations in certain countries. For example, certain chemicals might be restricted in some regions, or certain products might not meet safety standards. So you may need to restrict your variations per country.
- Shipping restrictions: Products with certain variations may be difficult or costly to ship to certain countries due to size, weight, or shipping regulations. By restricting your WooCommerce variations per country, you can avoid offering products that can’t be shipped to specific countries.
- Inventory management: Managing inventory for variations across different countries can be complex. By restricting variations per country, you can streamline inventory management and avoid overselling or underselling products in specific regions.
- Different prices and stock per country: If you want to sell a specific product and show different pricing and inventory per country, you can restrict variations per country and automatically hide the restricted variations.
Overall, restricting WooCommerce variations per country allows you to optimize your product offerings, comply with regulations, and provide a better shopping experience for customers in different regions.
However, that’s not possible with WooCommerce, because it doesn’t have any built-in setting to hide or restrict variations per country. That’s why, in this tutorial, we’ll use the WooCommerce Product Restrictions by Location plugin.
You can download the plugin here:
Download Country Catalogs for WooCommerce Plugin - or - Read more
Once you install the plugin and activate your license, you can follow the steps below in order to restrict product variations by country.
Step 1. Select the global settings
The first thing to do is to select what we are going to restrict (products and variations) and how we are going to restrict it (countries and continents).
To do this, go to WooCommerce > Settings > Restrictions by location.
Tick the Products and variations checkbox.
In I want to restrict by, select Countries/continents.
Enter the countries or continents for which you’ll sell different product variations.
Click on Save changes.
Move to the Header selector tab where you can select a navigation menu, on which you will display a country selector.
Once you do that, save the changes.
Step 2. Set up a product attribute for countries
We are going to create a product attribute called country, whose terms will be the names of the countries in which we want to sell our product variations.
To do this, go to Products > Attributes and create an attribute called “Country”.
Then, you can start adding country terms. In this example, we’ll add 4 countries: Canada, El Salvador, Mexico, United States.
Normally, variable products allow attributes to be selected on the product page, as you can see in the screenshot below.
However, you can select the “Country” attribute as the attribute you use for location restrictions, so that users from a certain country do not see that you have variations for other countries.
If you do this, users from El Salvador will only see the normal product, without realizing that it is a variable product. In the same way it will happen with users from Mexico, the United States, etc.
To do this, go to WooCommerce > Settings > Restrictions by Location > Variations per location.
Once there, select the “Country” attribute in Variations: Select the attribute used for storing the location to hide it.
Once you do that, click on Save changes.
Step 3. Create and restrict product variations per country
In this example we are going to edit one of our variable products.
The first thing we are going to do is to go to the Attributes tab and add the “Country” attribute, selecting all the terms and checking the “Used for variations” checkbox.
Let’s move to the Variations tab and add a variation for each country.
You need to edit each variation in order to make it available for the country it was created for. For example, if we edit the “Canada” variation, we need to move to the Location restrictions section and select “Canada” in Selected locations, and “Yes” in Available in selected locations.
You need to do the same with every variation you have created for a specific country. Variations with the country term “El Salvador” must be available for El Salvador; variations with the country term United States must be available for the United States; and so on.
Step 4. Test and see the results
As you can see in the screenshot below, our site displays the country selector in the navigation menu.
If we select “El Salvador”, you can see that the product shows a specific price and stock.
But if we select “Canada”, the product shows another price and stock.
This is how you can create and restrict variations for different countries. You can use that to comply with legal restrictions in different countries, respect shipping restrictions, or simply to show different pricing and stock for different countries.