Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mooore-digital/magento2-module-geoip

Magento 2 module providing basic Geo IP detection
https://github.com/mooore-digital/magento2-module-geoip

geo-ip-detection geoip ipinfo magento2 magento2-module

Last synced: about 1 month ago
JSON representation

Magento 2 module providing basic Geo IP detection

Awesome Lists containing this project

README

        

# Magento 2 GeoIp
Magento 2 module providing basic Geo IP detection.

## API

### REST
```bash
$ curl https:///rest/V1/countryCode
"NL"
```

### PHP
``` php
countryCode = $countryCode;
}

public function execute(): void
{
//output: Country is NL
echo sprintf('Country is %s', $this->countryCode->get());
}
}
```

## Installation
```bash
composer require mooore/magento2-module-geoip
bin/magento setup:upgrade
```

## Configuration
This module has a fallback reliance on several inputs:
1. [GeoIP](http://nginx.org/en/docs/http/ngx_http_geoip_module.html) variable `GEOIP_COUNTRY_CODE`.
2. [GeoIP2](https://github.com/leev/ngx_http_geoip2_module) variable `COUNTRY_CODE`.
3. [Cloudflare](https://www.cloudflare.com/) header `CF-IPCountry`.
4. [IpInfo.io](https://ipinfo.io/) API.

To be able to fall back on IpInfo.io, follow these steps:
1. Have an account at [ipinfo.io](https://ipinfo.io/) (usage is free for 50k requests per month).
2. Have the ipinfo.io API key.
3. Configure it in the Magento 2 backend (Advanced -> System -> GeoIP):
![Configuration](docs/configuration.png)