CSV Upload Restrictions

With the bulk upload feature you can use the native WooCommerce Product CSV Importer and Exporter to add restriction rules to many products at once, instead of editing each product individually.

Prepare the CSV File

The CSV file contains 4 columns. Use exactly these column headers and include all columns:

  • ID — the WooCommerce product ID. For variable products, use one row per variation with the variation ID (shown as #1234 in the product’s Variations tab), and a row with the parent ID if the parent has its own rule.
  • SKU — the product SKU. You can match products by ID or by SKU; the other cell can stay empty.
  • Meta: _fz_country_restriction_type — the restriction rule: 1 = Product Available for selected countries, 2 = Product not Available for selected countries, 0 = remove the rule.
  • Meta: _restricted_countries — the country codes for the rule, as two-letter ISO codes separated by commas (for example: US,CA,GB). Spaces are stripped and lowercase codes are converted automatically. Leave empty when the rule value is 0.

Example file:

ID,SKU,Meta: _fz_country_restriction_type,Meta: _restricted_countries
101,,1,"US,CA,GB"
102,,2,"IN,IL"
103,,0,
,TSHIRT-BLUE-M,1,"US,DE"

In this example: product 101 becomes available only in the US, Canada, and the UK; product 102 becomes unavailable in India and Israel; the rule on product 103 is removed; and the product with SKU TSHIRT-BLUE-M becomes available only in the US and Germany.

INFO
We recommend editing the CSV in Google Sheets or OpenOffice. Avoid Microsoft Excel — its formatting and character encoding changes can make the upload fail. An invalid country code doesn’t produce an error: it simply never matches any customer, so double-check your codes.
Example restrictions CSV with ID, SKU, and the two Meta columns

Import the CSV File

Products → All Products → Import
  • Go to Products → All Products — and click Import at the top of the page.
  • Choose your CSV file — and check Update existing products, so the importer updates your existing products instead of creating new ones. Click Continue.
  • Check the column mapping — the two Meta columns should map to Import as meta data automatically; ID and SKU map to their product fields.
  • Click Run the importer — the restriction rules are applied to the matched products.

The import overwrites the restriction rule of every product in the file (a value of 0 removes it). Products that are not in the file are untouched, and other product data is only changed if your file contains other columns.

WooCommerce product importer upload step with Update existing products checked
WooCommerce importer column mapping step with the CBR meta columns mapped as meta data

Export Existing Rules

To export your current restriction rules — for backup, review, or editing and re-importing — use the WooCommerce product exporter:

Products → All Products → Export → check "Yes, export all custom meta"

The exported file includes the Meta: _fz_country_restriction_type and Meta: _restricted_countries columns for every product that has a rule.

Next Steps