magefan / module-geoip
Allows to get country code by IP
Installs: 121 234
Dependents: 1
Suggesters: 0
Security: 0
Stars: 51
Watchers: 4
Forks: 10
Open Issues: 1
Type:magento2-module
Requires
- geoip2/geoip2: ^2.9.0
- magefan/module-community: >=2.1.16
Suggests
- magefan/module-auto-currency-switcher: Install GeoIP Auto Currency Switcher Extension for Magento 2 (https://magefan.com/magento-2-currency-switcher-auto-currency-by-country). Use coupon code COMPOSER-FAN to get a 10% discount on magefan.com.
- magefan/module-auto-language-switcher: Install GeoIP Auto Language/Store Switcher Extension for Magento 2 (https://magefan.com/magento-2-auto-language-switcher). Use coupon code COMPOSER-FAN to get a 10% discount on magefan.com.
This package is auto-updated.
Last update: 2024-04-12 08:21:09 UTC
README
This Magento 2 GeoIP module provides you PHP methods for getting customer country by IP, without any additional plugin for PHP.
It is used for Magento 2 Currency Auto Switcher and Magento 2 Auto Language Switcher by Magefan
Requirements
- Magento Community Edition 2.0.x-2.4.x or Magento Enterprise Edition 2.0.x-2.4.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
- Install GeoIP2 PHP API (https://github.com/maxmind/GeoIP2-php).
- 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.
This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com.
Originaly use this databases:
Magento 2 Extensions by Magefan
Magento 2 Admin Panel Extensions
- Magento 2 Admin Action Log
- Magento 2 Edit Order Extension
- Magento 2 Better Order Grid Extension
- Magento 2 Extended Product Grid
- Magento 2 Product Tabs Extension
- Magento 2 Facebook Pixel Extension
- Magento 2 Email Attachments
- Magento 2 Admin View Extension
- Magento 2 Admin Email Notifications
- Magento 2 Login As Customer Extension
Magento 2 Google Extensions
- Magento 2 Google Indexing API
- Magento 2 Google Analytics 4 Extension
- Magento 2 Google Tag Manager
- Magento 2 Google Shopping Feed
- Magento 2 Google Customer Reviews
Magento 2 SEO Extensions
- Magento 2 SEO Extension
- Magento 2 Rich Snippets Extension
- Magento 2 HTML Sitemap Extension
- Magento 2 XML Sitemap Extension
- Magento 2 Twitter Cards Extension
- Magento 2 Facebook Open Graph Extension
Magento 2 Blog Extensions
- Magento 2 Blog Extension
- Magento 2 Blog Plus Extension
- Magento 2 Blog Extra Extension
- Magento 2 Multi Blog Extension
- Magento 2 Product Widget Advanced Extension
Magento 2 Marketing Automation Extensions
- Magento 2 Product Labels
- Magento 2 Dynamic Categories
- Magento 2 CMS Display Rules Extension
- Magento 2 Automatic Related Products
- Magento 2 Price History
- Magento 2 Mautic Integration Extension
- Magento 2 YouTube Widget Extension
Magento 2 Cart Extensions
- Better Magento 2 Checkout Extension
- Magento 2 Coupon Code Link
- Magento 2 Convert Guest to Customer Extension
Magento 2 Speed Optimization Extensions
- Magento 2 Lazy Load Extension
- Magento 2 WebP Optimized Images Extension
- Magento 2 Rocket JavaScript Extension
Magento 2 Multi-Language Extensions
- Magento 2 Hreflang Tags Extension
- Magento 2 Auto Currency Switcher Extension
- Magento 2 Auto Language Switcher Extension
- Magento 2 GeoIP Switcher Extension
- Magento 2 Translation Extension
Developers Tools
- Magento 2 Zero Downtime Deployment
- Magento 2 Cron Schedule
- Magento 2 CLI Extension
- Magento 2 Conflict Detector Extension