magefan/module-geoip 2.0.0

Allows to get country code by IP

Type

magento2-module

License

None

Requires
Requires (dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Magento 2 GeoIp Extension by Magefan

Total Downloads Latest Stable Version

This Magento 2 Blog module allows you to get customer country by ip.

Requirements

  • Magento Community Edition 2.0.x-2.2.x or Magento Enterprise Edition 2.0.x-2.2.x

Installation Method 1 - Installing via composer

  • Open command line
  • Using command "cd" navigate to your magento2 root directory
  • Run command: composer require magefan/module-geoip
composer require magefan/module-geoip
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

Installation Method 2 - Installing using archive

  • Download ZIP Archive
  • Extract files
  • In your Magento 2 root directory create folder app/code/Magefan/GeoIp
  • Copy files and folders from archive to that folder
  • In command line, using "cd", navigate to your Magento 2 root directory
  • Run commands:
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

How To Use

protected $ipToCountryRepository;

public function __construct(
    \Magefan\GeoIp\Model\IpToCountryRepository $ipToCountryRepository,
    ....//other code
) {
    $this->ipToCountryRepository = $ipToCountryRepository;
    ...//other code
}

public function example() {
    $visitorCountyCode = $this->ipToCountryRepository->getVisitorCountryCode();
    $someCountryCodeByIp = $this->ipToCountryRepository->getCountryCode('104.27.164.57');
    ...//other code
}

Support

If you have any issues, please contact us then if you still need help, open a bug report in GitHub's issue tracker.

Need More Features?

Please contact us to get a quote https://magefan.com/contact

License

The code is licensed under Open Software License ("OSL") v. 3.0.