Magento 2 GeoIP Database Extension by Magefan
magefan/module-geoip
Provides PHP methods to determine a customer's country based on their IP address. Enables features like automatic currency and language switching.
Build Tests
Code Quality
Tested on Magento 2.4.8-p3
Recent Test History
Each release is tested against the latest Magento version at that time.
Top Contributors
View LeaderboardShare This Module's Status
README
Loaded from GitHubMagento 2 GeoIP Database Extension by Magefan
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
🇺🇦 Stand with Ukraine! How can you help?
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 and MaxMind EULA.
This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com.
Originally use these databases:
https://www.maxmind.com
http://software77.net/geo-ip/
Magento Extensions by Magefan
Magento 2 SEO Extensions
- Magento SEO
- Magento 2 Rich Snippets
- Magento 2 HTML Sitemap
- Magento 2 XML Sitemap
- Magento 2 Twitter Cards
- Magento Open Graph Tags
Magento 2 Google Extensions
- Magento Google Tag Manager
- Magento 2 Google Analytics 4
- Magento Google Shopping Feed
- Magento Google Customer Reviews
- Magento 2 Google Indexing
Magento Speed Optimisation Extensions
- Magento 2 Google Page Speed Optimizer
- Magento 2 WebP Images
- Magento Full Page Cache Extension
- Magento 2 Lazy Load Images
- Magento 2 Defer JavaScript
Magento Admin Extensions
- Magento 2 Dynamic Category
- Magento 2 Size Chart
- Magento 2 Security Extension
- Magento 2 Admin Action Log
- Magento Extended Product Grid
- Magento 2 Product Tabs
- Magento 2 Product Widget
- Magento 2 Email Attachments
- Magento 2 Admin View
- Magento 2 Email Notifications
- Magento 2 Login As Customer
Magento Order Management Extensions
Magento 2 Blog Extensions
Magento Marketing Extensions
- Magento 2 Facebook Pixel
- Magento TikTok Pixel
- Magento 2 Dynamic Blocks and Pages
- Magento 2 Cookie Consent
- Magento 2 Base Price
- Magento 2 Price History
- Magento 2 Mautic Extension
- Magento 2 YouTube Video
Magento Promotions Extensions
Magento 2 Multi-Language Extensions
- Magento 2 Hreflang Tags
- Magento 2 Currency Switcher
- Magento 2 Language Switcher
- Magento 2 Store Switcher
- Magento 2 Translation Extension
Developers Tools
- Magento Zero Downtime Deployment
- Magento 2 Cron Schedule
- Magento 2 CLI Extension
- Magento 2 Conflict Detector
Shopify Apps by Magefan
- Shopify Login As Customer
- Shopify Blog
- Shopify Size Chart
- Shopify Google Indexer
- Shopify Product Feeds
- Shopify Server GTM & GA4
Magento 2 Services by Magefan
This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.