Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The plugin should be able to detect the visitor's currency #6

Open
wvega opened this issue Feb 5, 2017 · 3 comments
Open

The plugin should be able to detect the visitor's currency #6

wvega opened this issue Feb 5, 2017 · 3 comments
Assignees

Comments

@wvega
Copy link
Collaborator

wvega commented Feb 5, 2017

This issue is about discussing the possible approaches to detect the visitor's currency, choose one and implement that solution.

@dgiraldo36
Copy link
Collaborator

To get the visitor's currency, I used the geoplugin.com service, by adding the following function to AUCP_Currency_Conversion class:

public function detect_currency_byIp(){
        $userIP = $_SERVER['REMOTE_ADDR'];
        $request = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$userIP)); 
        $retVal = ($request['geoplugin_status'] != 404) ? strtoupper($request['geoplugin_currencyCode']) : 'USD' ;
        return $retVal;
    }

it returns the 3-letter code if available, otherwise returns 'USD'.

@dgiraldo36
Copy link
Collaborator

If we want to avoid the http request, we can include de geoip lib and do the geolocation using the function:

geoip_country_code3_by_name($_SERVER['REMOTE_ADDR'])

Returns the three letter country code on success, or FALSE if the address cannot be found in the database.

@jorgeatorres jorgeatorres self-assigned this Apr 10, 2017
@wvega wvega modified the milestone: 1.0 Apr 10, 2017
@jorgeatorres jorgeatorres removed this from the 1.0 milestone Apr 10, 2017
@jorgeatorres
Copy link
Collaborator

After a discussion with @wvega we decided to postpone this until after 1.0.
Some implementation details:

  • Detection should be attempted after page load using AJAX.
  • Stored target currency (see The plugin should store the selected (or detected) currency #7) should take precedence over this (i.e. not trigger the IP detection).
  • If a currency is detected, conversion shouldn't happen automatically. We think users should be informed (somehow) about the detected currency and let them accept it (or change it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants