Contents
Get Geolocation Source - Plugixa Multi Currency for WooCommerce
GET /plugixa-multi-currency/v1/geo
What Pick the currency from the shopper’s country can rely on, with every country and the currency it gets by default.
Needs a user with the plugixa_multi_currency_manage_settings capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators hold it; see Capabilities.
Note. Pro only: on the free plugin this route answers
404rest_no_route.
Request
GET https://your-store.example/wp-json/plugixa-multi-currency/v1/geo
Responses
200 OK.
{
"success": true,
"data": {
"source": "header",
"header": "HTTP_CF_IPCOUNTRY",
"maxmind_settings": "https://your-store.example/wp-admin/admin.php?page=wc-settings&tab=integration§ion=maxmind_geolocation",
"countries": {
"AF": "Afghanistan",
"AL": "Albania",
"...": "..."
},
"default_map": {
"AD": "EUR",
"AE": "AED",
"...": "..."
}
}
}
| Field | Type | Meaning |
|---|---|---|
source |
string |
maxmind (WooCommerce’s MaxMind database), header (a country header from the server or CDN) or none |
header |
string |
The header found: MM_COUNTRY_CODE, GEOIP_COUNTRY_CODE, HTTP_CF_IPCOUNTRY or HTTP_X_COUNTRY_CODE. Empty when none |
maxmind_settings |
string |
WooCommerce’s MaxMind settings screen |
countries |
object |
WooCommerce’s countries, code to name |
default_map |
object |
Each country’s own currency. Your country_map overrides it |
The header is read from the request that asked, so behind a CDN the answer depends on the request passing through it.
Errors
| Status | Code | When |
|---|---|---|
401 / 403 |
rest_forbidden |
The caller lacks the capability: Sorry, you are not allowed to do that. |
Plus the errors every endpoint can return.
Examples
curl -s "https://your-store.example/wp-json/plugixa-multi-currency/v1/geo" \
-u "$WP_USER:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-multi-currency/v1/geo');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-multi-currency/v1/geo', {
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
},
});
const { data } = await response.json();
Quick Links
Share