Part of the Commerce ecosystem · 506 projects
Commerce Visitor Country Condition adds a Commerce condition on the country the visitor is browsing from, as GeoIP reads it from the request. A store can run a promotion only for visitors from Spain, hide a payment method outside Portugal or offer a shipping method to some countries, all decided from the first page view, before the customer has typed an address.
Features
- ๐๏ธ Promotions for some countries. Tick Visitor country (GeoIP) on a promotion and pick the countries, or the countries to leave out. It combines with Commerce's other conditions, with coupons and with usage limits.
- ๐ Wherever Commerce takes order conditions. The same condition is offered on payment gateways and, with Commerce Shipping, on shipping methods, so a method can be shown or hidden by where the visitor is.
- ๐ Decided by the request, not the order. Like Commerce's own User role, the condition ignores the order and compares the country of the current request, so it already answers on the cart, before any address exists. A visitor GeoIP cannot place is in no list.
- โก Safe on cached pages. The condition carries its own cache metadata, the
geoip_countrycache context by default, so code that shows the result of a promotion on a cached product page can make the page vary by country with one line. - ๐ Your own country rule. The country comes from one service that a site decorates or replaces: a country the customer picked, a header set by its own proxy, an exception for its office. The condition passes on that service's cache metadata.
Quick start
composer require drupal/commerce_visitor_country_condition:@beta drush en commerce_visitor_country_condition
- At Configuration > System > Configure GeoIP, choose how GeoIP finds the country. Behind Cloudflare or Amazon CloudFront, the default, CDN, reads the header they send.
- Go to Commerce > Promotions and add or edit a promotion.
- Under Conditions, open the Current request tab, tick Visitor country (GeoIP), choose Is one of or Is not one of and pick the countries, then save.
- Add a product to the cart from one of those countries: the promotion's line appears in the order summary, and visitors from elsewhere do not get it.
The cart of a visitor from Portugal, with a promotion limited to Portugal and Spain.
Good to know
- The country is where the request comes from, which a VPN or a corporate proxy can change. For a decision that must follow the customer's address, such as taxes, use Commerce's address conditions, which read the order's billing or shipping address once it is known.
- Commerce does not ask conditions for cache metadata, and carts and checkout are not cached, so promotions, payment gateways and shipping methods need nothing more. Code that evaluates the condition for a cached response adds it as a cacheable dependency; the README shows how.
- GeoIP keeps the country of each IP address in its own cache. Clear it with the
geoipcache tag after changing how GeoIP locates visitors.
Additional requirements
- Drupal 10.3 or 11.
- Commerce Core 3, with its Order module; Promotion for promotions, Payment for payment gateways.
- GeoIP API 3.1 or later, set up to locate visitors: a CDN header, a MaxMind database or the MaxMind web service.
Community documentation
- README: configuration, caching, and how to plug in a country rule of your own.
Supporting this module
Developed and maintained by Bloomidea. Bloomidea offers support and custom development for this module.
Ask your assistant about Commerce Visitor Country Condition
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
More in the Commerce ecosystem
Most installed first
Activity
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 1.x-dev | Dev | 10โ11 | PHP >=8.1 | Nov 29, 2026 | |
| 1.0.0-beta1 | Pre-release | 10โ11 | PHP >=8.1 | Nov 29, 2026 |