The Country Catalogs for WooCommerce plugin helps you hide products from selected countries. However, if you need to edit hundreds of product country restrictions, you may spend several hours opening and editing your products one by one. Fortunately, we have CSV files. They help us edit hundreds of products in Excel or Google Sheets.
Therefore, we’ll show you how to edit hundreds of product country restrictions in a CSV file and how to import it to WooCommerce.
Of course, you need to have the Country Catalogs for WooCommerce plugin installed and activated to edit your product country restrictions.
Edit one of your products
It’s important to edit one of your products to assign the countries where you want to restrict them because the plugin creates an abbreviated name for each country in your products’ metadata.
That means that you can select United States as the country, but in fact, the plugin will add US to the metadata, or you can select Mexico and the plugin will add MX to the metadata.
Therefore, in order not to make mistakes, you need to edit one of your products. But it’s really simple. You just need to go to Products in wp-admin and then open one product to edit it.
Once you open the product, you need to go to Product data > General > Country Restrictions.
Once there, you need to select these values to hide that product in a specific country.
- Selected countries: United States, for example
- Available in selected countries: No
- Click on Update
Export your products and edit them in a CSV file
After setting the product’s country restrictions, you need to go to Products and click on Export to obtain a CSV file with your products.
To export the CSV file, you need to take these two simple steps:
- Tick the Yes, export all custom meta checkbox.
- Click on Generate CSV.
Once you’ve downloaded the CSV file, you need to edit it with Excel or with Google Sheets.
In order to make it easier, you can delete all unnecessary columns. You just need the following columns:
- Meta: vcwccr_availability_operator
- Meta: vcwccr_selected_countries
- Meta: wcacr_disallowed_countries
Important. The vcwccr_selected_countries column is for the countries you have selected. The wcacr_disallowed_countries column is for the countries where your products are not allowed. The vcwccr_availability_operator column marks whether the products are available (1=Yes) or unavailable (0=No).
Therefore, you need to use these columns and values to restrict your products in the USA.
- Meta: vcwccr_availability_operator: 0
- Meta: vcwccr_selected_countries: US
- Meta: wcacr_disallowed_countries: US
After setting these values on the columns, go to File > Download as > Comma-separated values (.csv, current sheet) to download the updated CSV file, which you’ll then import to WooCommerce.
Import the CSV file to WooCommerce
To import the CSV file to WooCommerce, you need to go to Products and click on Import.
After that, you need to do the following:
- Select the CSV file from your computer.
- Tick the Existing products that match by ID or SKU will be updated checkbox.
- Click on Continue.
Finally, you need to match the CSV columns to the WooCommerce fields. For that, you just need to select these values:
- ID: ID
- Name: Name
- Meta: vcwccr_availability_operator: Import as meta
- Meta: vcwccr_selected_countries: Import as meta
- Meta: wcacr_disallowed_countries: Import as meta
- Click on Run the importer
That’s it. Your import process will start and be completed in just some seconds:
This way, you can apply country restrictions to thousands of products in just some minutes. Now it’s evident that editing your product country restrictions in a CSV file in Excel or Google Sheets is really simple!