| 开发者 |
dhimahisolutions
windcodex |
|---|---|
| 更新时间 | 2026年11月25日 17:43 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.0 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
CF-Connecting-IP automatically for sites behind Cloudflare.[geoblock_show], [geoblock_hide] and [geoblock_country] show or hide any content by visitor country, on any page or post.{country_name}, {country} and {country_flag} in your restriction message.[geoblock_product_message] renders the restriction message in any page builder, custom template, Elementor, or Divi..pot file included. Compatible with Loco Translate and WPML String Translation.subscription and variable-subscription product types fully supported.SGCACHENOCACHE and sgo_bypass_cache.[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"][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.windcodex-geoblock folder to /wp-content/plugins/.No paid service or GeoBlock account is needed. GeoBlock uses WooCommerce's own geolocation. If your host or CDN passes the visitor's country (for example Cloudflare), that works with no extra setup. Otherwise WooCommerce looks up the country in the MaxMind GeoLite2 database, which needs a free MaxMind license key under WooCommerce > Settings > Integration. The lookup runs on your own server. Customers with a saved shipping or billing address are detected from that address either way.
All countries supported by WooCommerce – the same full list used in WooCommerce shipping and tax settings. You can restrict any single country or any combination of countries on each product independently.
Open the product in your WordPress admin, find the GeoBlock - Country Restrictions meta box, select Exclude, choose the countries you want to block, and save. That country's visitors will be blocked immediately.
Yes. Select Include mode in the meta box and choose the countries that are allowed to purchase. All other countries will be restricted automatically.
Yes. Set WooCommerce's "Default customer location" to Geolocate (with page caching support) (AJAX mode). Country detection happens via AJAX after page load, so it works correctly on fully cached pages. GeoBlock also includes a built-in WP Rocket compatibility layer that excludes product pages from cache.
GeoBlock shows a warning banner in the plugin settings page. Without geolocation, guest visitors fall back to the store's base country and restrictions will not apply to them. Logged-in customers with a saved shipping or billing address are still detected correctly.
Yes. Country rules are set at the parent product level and automatically apply to all variations. In Hide and Catalog Only modes, the entire product including all variations is restricted. In Message mode, variation dropdowns and the Add to Cart button are both hidden on the product page.
GeoBlock detects country based on IP address. A customer using a VPN may appear to be in a different country. For stores where VPN circumvention is a concern, enable the "Force Geolocation" option, which ignores saved addresses and always uses current IP detection.
GeoBlock automatically removes restricted products from the cart when the customer visits the cart or checkout page, and displays a clear notice explaining why. Checkout is also blocked as a final safety net even if the cart page was skipped.
Yes. Each product has its own independent set of rules. Product A can be restricted to Europe only, Product B excluded from one specific country, and Product C open to everyone – all at the same time.
Search engine crawlers are detected by IP like any other visitor. Googlebot crawls mostly from US IP addresses, so if you use Hide completely for the US, Google may see a 404 and drop that product from its index. To keep restricted products indexed, turn on Never restrict search engine and link-preview bots in the Advanced tab, or use Show Restriction Message or Hide from Catalog for countries your main crawlers come from. Products open to the crawler's country are indexed normally.
Yes. Wrap content in [geoblock_show countries="US,CA"]...[/geoblock_show] to show it only to those countries, or [geoblock_hide countries="EU"]...[/geoblock_hide] to show it to everyone else. You can use country codes or region names such as EU, EEA and NORDICS.
Turn on Debug Mode in WooCommerce > GeoBlock Restrictions > Advanced, then use the "Test as" picker in the toolbar at the bottom of your site. Only you see it, and an admin-bar notice reminds you while it is active.
GeoBlock uses the visitor's IP address only to work out their country, keeps the result for one hour (WooCommerce session and WordPress transient), and sends no data to external services. Whether your whole store meets GDPR depends on your setup, so mention country detection in your privacy policy and check with your own advisor.
Yes. GeoBlock's compatibility layer hooks into WooCommerce Subscriptions' own purchasability filters and fully supports both subscription and variable-subscription product types.
Yes. Use the [geoblock_product_message id=PRODUCT_ID] shortcode in any page builder element or custom template to display the restriction message anywhere on your site.
Enable Debug Mode in WooCommerce > GeoBlock Restrictions > Advanced. An admin-only debug toolbar will appear at the bottom of every frontend page showing the detected country, IP address, and detection method. You can also temporarily set your own country as a restricted country to verify the hide or message behaviour.
No. In Hide completely mode, the direct product URL returns a 404 page. You can also configure a redirect URL to send restricted visitors to a custom page (like a contact or coming-soon page) instead of a 404.
GeoBlock uses a 6-layer detection chain: (1) shipping address, (2) billing address, (3) WooCommerce session, (4) WordPress transient cache, (5) MaxMind GeoLite2 database via WooCommerce's built-in engine, (6) store base country fallback. Results are cached per session to avoid repeated lookups.
Yes. WooCommerce Blocks compatibility is declared. Cart and checkout protection applies regardless of whether classic or block-based cart and checkout is used.
[geoblock_show], [geoblock_hide] and [geoblock_country] shortcodes to show or hide any content by visitor country.{country_name}, {country} and {country_flag} placeholders in the restriction message.geoblock_region_groups, geoblock_is_exempt_visitor, geoblock_crawler_pattern and geoblock_shortcode_disable_cache filters.load_plugin_textdomain() for full compatibility with translation plugins (Loco Translate, WPML String Translation) and manually installed language packs..pot translation template with the latest translatable strings.CF-Connecting-IP header support for reverse-proxied sites.woocommerce_add_to_cart_validation blocks API/AJAX bypass attempts.[geoblock_product_message] shortcode for page builder and custom template compatibility..pot file included.