in my website i have 2 currency & user can. One is USD and other is Riyal. Default currency is USD . There is drop down in near to our logo in which customer can change the currency to Riyal and USD. Default option is USD
What i want is, any customer taking our website from Saudi Arabia we have to show them riyal currency for all other country we have to show them USD Curreny .
How can i do this ? Please help.
For this work, you need to check your ip from $_SERVER['REMOTE_ADDR'] and find the country code from MaxMind’s GeoIP2 database(https://dev.maxmind.com/geoip/geoip2/geolite2/).
Reference: https://www.w3resource.com/php-exercises/php-basic-exercise-5.php
After that, you need to use event observer controller_action_predispatch in your module in app/code/your_vendor/your_module/etc/frontend/events.xml
In the your_vendor\your_module\Observer\PreDispatchObserver.php file you need to add: