WooCommerce – Stock and Inventory Based on the User Country

In this tutorial we want to show you how to show stock and inventory based on the country of your users or customers in WooCommerce.

For example, we are going to show you how to create an inventory for a specific country and another inventory for the rest of the world.

With this simple method you could even create a specific inventory for each country. Of course, if you want to do it with WooCommerce, it’s simply impossible.

Well, even if it’s not impossible, it’s too difficult because you would have to use PHP snippets, which make life difficult for us and make us spend a lot of time trying to get what we want to do.

For this, we’ll use the Country Catalogs for WooCommerce plugin, which allows you to create different conditions to restrict products, variations, categories, etc., for different specific countries.

You can download the plugin here:

Download Country Catalogs for WooCommerce Plugin - or - Read more

After installing and activating the plugin, just follow these simple steps.

1- Edit the plugin’s global settings

To edit the plugin’s global settings, go to WooCommerce > Advanced Country Restrictions and click on Open global settings.

After that, you need to select the following values in the General settings:

  • Geolocation method: We will show a country or state selector in the header
  • Restriction method: Hide product from the catalog
  • Restrict by: Country and continents
  • Hit Save changes.

2- Create a Country product attribute

Go to Products > Attributes.

Once there, create an attribute called Country. This will be useful to create variations for those attributes and show different stock per country.

You can create an attribute for each country where you’ll define a specific stock, or create a country and another attribute for the rest of the world.

We’ve created a country called El Salvador and another called World. This way, we will show a stock for El Salvador and a stock for the rest of the world.

3- Make your product variable and select the country attributes

Go to Products and open the product you’ll edit.

Once you open the product for which you’ll create different stock for different countries, you need to:

  1. Convert the product into variable
  2. Select the country attributes
  3. Create the variations you’ll use to show different stock for different countries

To make the product variable, select Variable product in the Product data dropdown.

After that, go to the Attributes section and add the country attributes to the products.

You must tick the Used for variations checkbox to use these attributes for the variations you’ll need to create.

Now you need to create the variations:

  1. Go to the Variations section
  2. Add a variation for each country

In this example, we’ll create only two variations: El Salvador and World.

Then you just need to edit these variations’ stock and country restrictions.

a) Edit stock and country restrictions for the first variation

The variation for El Salvador must not be available for the rest of the world, so you need to do this to restrict it in all countries except in El Salvador:

Edit the variation stock:

You need to open the variation options and then tick the Manage stock checkbox.

Next, enter the stock in the Stock quantity field.

Edit the variation country restrictions:

Go to the Selected countries field and select all the countries where you want this variation to be restricted.

Since this variation is just for El Salvador, you should select all other countries in the Selected countries field.

In Available in selected countries, you need to select No.

b) Edit stock and country restrictions for the second variation

Now it’s time to edit the variations for the rest of the world. This one should be available for all countries, but not for El Salvador.

Edit the variation stock:

Open the variation options and tick the Manage stock checkbox.

After that, enter the stock in the Stock quantity field.

Edit the variation country restrictions:

Go to Selected countries and select El Salvador.

In Available in selected countries, you need to select No.

Finally, click on Save changes.

4- See the results

Once you’ve edited the variations, you’ll notice that users visiting your store from El Salvador will be able to see the stock you entered for the El Salvador variation.

On the other hand, users visiting from the rest of the world will be able to see the World variation and its stock only.

Important. We’re dealing with just two variations, but you can create a variation for each country and just play with the restricted countries.

That’s a piece of cake!

You see? That was really simple. You just need to use some fields and follow some simple steps. You can create different stock for all countries you want and don’t need to use PHP snippets nor spend lots of hours.

You can download the plugin here:

Download Country Catalogs for WooCommerce Plugin - or - Read more