WindCodex GeoBlock – WooCommerce Country Restriction & Geo Blocking
Restrict WooCommerce products by country: hide them, block purchase or sell only to chosen countries.
Install in
WindCodex GeoBlock lets you restrict WooCommerce products by country using WooCommerce’s built-in geolocation – no paid API, no third-party service, no code required.
Whether you need to comply with local laws, honour export restrictions, manage licensing territories, or simply limit shipping to countries you serve – GeoBlock gives you per-product country control in minutes.
Why Store Owners Choose GeoBlock
- Stop failed deliveries – Block customers from ordering products you cannot ship to their location.
- Stay legally compliant – Restrict alcohol, supplements, age-restricted, or regulated products by region.
- Honour licensing agreements – Limit digital downloads and licensed content to permitted territories.
- Build country-specific catalogs – Show a tailored product range to each market automatically.
- Reduce chargebacks – Prevent orders you would only have to cancel and refund anyway.
3 Restriction Modes
Hide Completely
Product disappears from shop pages, search results, and category listings. The direct product URL returns a 404 page. Optionally redirect restricted visitors to any custom URL instead.
Hide from Catalog – Allow Direct URL
Product is hidden from the shop and search but remains accessible via its direct link. Useful for distributors or B2B partners in restricted regions. A single toggle lets direct-URL visitors purchase too.
Show Restriction Message
Product stays visible in the catalog. On the product page, the Add to Cart button and price are replaced with your custom HTML message – ideal for explaining regional availability without hiding the product entirely.
Key Features
- Per-product country rules – Set include or exclude rules on any product from the product edit screen, with a searchable country selector and live rule summary.
- Include or Exclude mode – Whitelist specific countries (only they can buy) or blacklist countries (everyone except them can buy).
- Custom restriction message – Write your own HTML message with links, bold text, or any WordPress-allowed markup.
- Configurable message position – Place the restriction notice above the title, below the title, after the description, or before product meta.
- Redirect on restriction – In Hide mode, send restricted visitors to any URL instead of a 404 page.
- Cart & checkout protection – Restricted products added to cart before a rule was applied are automatically removed, with a clear customer notice.
- Server-side add-to-cart validation – Blocks direct POST, REST API, and AJAX add-to-cart attempts. Not just client-side.
- Smart country detection (6 layers) – Shipping address billing address WC session transient cache MaxMind GeoLite2 store base country. No manual input needed.
- Cloudflare IP support – Reads
CF-Connecting-IPautomatically for sites behind Cloudflare. - Force Geolocation option – Ignore saved addresses and always detect country from current IP.
- Session & transient caching – Country detection results cached per session. Zero repeated geolocation lookups.
- Admin debug toolbar – Shows detected country, IP address, detection source, and a settings link. Visible to admins only.
- Test as country – Preview your store as a visitor from any country from the debug toolbar. Admin-only, with an admin-bar reminder so you never forget you are testing.
- Country content shortcodes –
[geoblock_show],[geoblock_hide]and[geoblock_country]show or hide any content by visitor country, on any page or post. - Region presets – Add the EU, EEA, North America, Nordics, GCC, ASEAN or Australia & NZ to a rule in one click.
- Message placeholders – Use
{country_name},{country}and{country_flag}in your restriction message. - Search bot exemption – Optionally let Googlebot, Bingbot and link-preview crawlers always see restricted products so Hide mode cannot hurt your search visibility.
- Admin bypass – Optionally never restrict administrators and shop managers.
- Setup health check – A Status tab that checks geolocation, country data source, page caching and your detected country.
- Shortcode support –
[geoblock_product_message]renders the restriction message in any page builder, custom template, Elementor, or Divi. - HPOS compatible – Fully supports WooCommerce High-Performance Order Storage.
- Translation ready – Complete
.potfile included. Compatible with Loco Translate and WPML String Translation.
Plugin Compatibility
Built-in compatibility for 6 popular plugins – no configuration needed:
- Price Based on Country for WooCommerce – Restriction message takes priority over country-based pricing on restricted products.
- WPML – Rules set on the original-language product automatically apply to all translated copies. No duplicate rules per language.
- WooCommerce Product Bundles – Restricting the bundle parent blocks the entire bundle from purchase.
- WooCommerce Subscriptions – Both
subscriptionandvariable-subscriptionproduct types fully supported. - WP Rocket – Product pages automatically excluded from page cache so every visitor gets the correct restricted or unrestricted version.
- Speed Optimizer by SiteGround – Product pages bypass SiteGround’s dynamic cache via
SGCACHENOCACHEandsgo_bypass_cache.
Use Cases
- Block alcohol or age-restricted products from countries where they are prohibited by law
- Restrict physical goods to only the countries you ship to
- Limit digital downloads to licensed territories
- Hide out-of-stock regional variants from international markets
- Display a “contact us to order in your region” message instead of hiding the product
- Build exclusive country-specific product catalogs for different markets
Shortcode
Display the restriction message anywhere on your site using:
[geoblock_product_message]
Attributes:
* id – Product ID to check. Defaults to the current product in the loop.
* class – Extra CSS class(es) added to the message wrapper div.
Examples:
[geoblock_product_message id=123]
[geoblock_product_message id=123 class=”my-notice highlight”]
Country Content Shortcodes
Show or hide any content by the visitor’s country:
[geoblock_show countries="US,CA"]Free shipping to North America[/geoblock_show]
[geoblock_hide countries="EU"]Prices exclude VAT[/geoblock_hide]
[geoblock_country format="flag_name"]
Attributes:
* countries – Comma-separated country codes and/or region names: EU, EEA, NORTH_AMERICA, NORDICS, GCC, ASEAN, ANZ.
* format ([geoblock_country] only) – name (default), code, flag or flag_name.
Pages that use these shortcodes are marked as not cacheable (DONOTCACHEPAGE) so one country never sees another country’s version. Use the geoblock_shortcode_disable_cache filter to turn this off.
How It Works
- Install and activate the plugin.
- Go to WooCommerce > GeoBlock and choose a restriction mode.
- Open any product and find the GeoBlock – Country Restrictions meta box.
- Select Include or Exclude, choose your countries, and save.
- GeoBlock automatically detects each visitor’s country and applies your rules in real time.
Requirements
- WordPress 6.9 or higher
- WooCommerce 7.0 or higher
- PHP 7.4 or higher
- WooCommerce Geolocation must be enabled: WooCommerce Settings > General > Default customer location > Geolocate
- For IP lookups, either a free MaxMind license key (WooCommerce > Settings > Integration) or a host/CDN that passes the visitor’s country, such as Cloudflare
GeoBlock Pro
The free plugin is fully working. GeoBlock Pro adds bulk category rules, payment gateway restrictions by country, variation-level rules and an analytics dashboard.
More Free Plugins from WindCodex
Privacy
GeoBlock uses the visitor’s IP address solely to determine their country. No personal data is stored permanently. Detection results are cached in WooCommerce session storage and WordPress transients with a 1-hour TTL. No data is sent to external servers. This plugin does not collect, sell, or share any visitor data.
Written by Joobi from the project's own listing. See the source page
1.1.0
- Added:
[geoblock_show],[geoblock_hide]and[geoblock_country]shortcodes to show or hide any content by visitor country. - Added: “Test as country” picker in the admin debug toolbar, plus an admin-bar reminder while testing.
- Added: Region presets (EU, EEA, North America, Nordics, GCC, ASEAN, Australia & NZ) on the product country selector.
- Added:
{country_name},{country}and{country_flag}placeholders in the restriction message. - Added: Setting to never restrict search engine and link-preview bots.
- Added: Setting to never restrict administrators and shop managers.
- Added: Status tab with a setup health check.
- Added:
geoblock_region_groups,geoblock_is_exempt_visitor,geoblock_crawler_patternandgeoblock_shortcode_disable_cachefilters. - Fixed: The debug toolbar could not be switched off from the settings page.
1.0.3
- Added: “Docs” link next to “Settings” on the Plugins screen.
- Added: Support Forum link in the Help menu.
- Improved: Refreshed Help menu design. The menu now closes with the Escape key and is correctly announced to screen readers.
- Improved: Uninstalling GeoBlock now removes all of its settings and per-product restriction rules. If GeoBlock Pro is active, nothing is removed, because Pro uses the same settings and rules.
1.0.2
- Added: Loads plugin translations via
load_plugin_textdomain()for full compatibility with translation plugins (Loco Translate, WPML String Translation) and manually installed language packs. - Updated: Regenerated the
.pottranslation template with the latest translatable strings.
1.0.1
- Improved: Settings page UI for better usability.
- Added: Admin review request notice.
- Added: Pro features notice.
1.0.0
- Initial release.
- Three restriction modes: Hide completely, Hide from catalog (Catalog Only), Show restriction message.
- Per-product Include/Exclude country rules with searchable Select2 country selector.
- Custom restriction message with HTML support and configurable position on product page (4 positions).
- Redirect URL option for Hide completely mode.
- Allow purchase via direct URL toggle for Catalog Only mode.
- 6-layer country detection: shipping address billing address WC session transient cache MaxMind GeoLite2 store base.
- Cloudflare
CF-Connecting-IPheader support for reverse-proxied sites. - Session and transient caching for geolocation performance (1-hour TTL).
- Force Geolocation option to ignore saved addresses and always use IP detection.
- Cart and checkout protection – restricted products auto-removed if added before rule was applied.
- Server-side add-to-cart validation via
woocommerce_add_to_cart_validationblocks API/AJAX bypass attempts. - Variation ID parent resolution – rules on parent product correctly block all child variations.
[geoblock_product_message]shortcode for page builder and custom template compatibility.- Admin debug toolbar (admin-only) showing country, IP, and detection source.
- AJAX save and reset with toast notifications and sticky footer save bar.
- HPOS (High-Performance Order Storage) compatibility declared.
- WooCommerce Blocks compatibility.
- Built-in compatibility: Price Based on Country, WPML, WooCommerce Product Bundles, WooCommerce Subscriptions, WP Rocket, Speed Optimizer by SiteGround.
- Translation-ready with complete
.potfile included.
Follow this listing's changes (Atom feed)