Contents
On this page
Update Detection Settings - Plugixa Multi Currency for WooCommerce
PUT /plugixa-multi-currency/v1/pro/detection
Save the detection sources. Only the fields you send change. PUT and POST work the same way. Geolocation and the country overrides are saved with Update Settings (geo_detect, country_map).
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
PUT https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/detection
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
language |
boolean |
No | Pick the currency from the page language. |
billing_country |
boolean |
No | Pick it from a signed-in customer’s saved address. |
cloudflare |
boolean |
No | Pick it from Cloudflare’s visitor country header. |
checkout_country |
boolean |
No | Switch to the currency of the country entered at checkout. |
country_field |
string |
No | billing or shipping: which address counts. |
language_map |
object |
No | Language code to currency code. |
language_map replaces the whole map. Lines whose currency is not in your list are dropped.
{
"language": true,
"language_map": {
"fr": "EUR",
"de": "EUR",
"ja": "JPY"
}
}
Responses
200 OK. data is the settings as saved, as in Get Detection Settings.
{
"success": true,
"data": {
"language": true,
"billing_country": true,
"cloudflare": false,
"checkout_country": true,
"country_field": "billing",
"language_map": {
"fr": "EUR",
"de": "EUR",
"ja": "JPY"
},
"plugin": "Polylang",
"languages": {
"en": "English",
"fr": "Français",
"de": "Deutsch",
"ja": "日本語"
},
"cloudflare_seen": false
}
}
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 -X PUT "https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/detection" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"language":true,"language_map":{"fr":"EUR","de":"EUR","ja":"JPY"}}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/detection');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'language' => true,
'language_map' => [
'fr' => 'EUR',
'de' => 'EUR',
'ja' => 'JPY',
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/detection', {
method: 'PUT',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ language: true, language_map: { fr: 'EUR', de: 'EUR', ja: 'JPY' } }),
});
const { data } = await response.json();
Quick Links
Share