Contents
On this page
Update Rates Now - Plugixa Multi Currency for WooCommerce
POST /plugixa-multi-currency/v1/rates/update
Fetch today’s rates now, like Update rates now in Settings > Exchange rates. Each source is tried in order until every currency has a rate. See Exchange rates.
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. This calls the rate sources over the internet: the European Central Bank and its mirror Frankfurter, and with Pro the providers you switched on. It works whether automatic updates are on or off.
Request
POST https://your-store.example/wp-json/plugixa-multi-currency/v1/rates/update
Request body
Content type: application/json
No body.
Responses
200 OK. data has one line per currency except the store currency.
{
"success": true,
"data": [
{
"code": "EUR",
"old": "0.9234",
"new": "0.9099181073",
"provider": "ecb",
"status": "applied",
"message": null
},
{
"code": "GBP",
"old": "0.7891",
"new": "0.7619199272",
"provider": "ecb",
"status": "applied",
"message": null
},
"..."
]
}
| Field | Type | Meaning |
|---|---|---|
code |
string |
The currency |
old |
string |
Its rate before the update |
new |
string|null |
The rate the source gave, null when none was fetched |
provider |
string|null |
The source used, for example ecb |
status |
string |
applied, unchanged, held (Pro rate alerts), rejected, locked (manual only) or unavailable |
message |
string|null |
Why, for every status except applied and unchanged |
A currency no source publishes comes back unavailable with No free source publishes this currency. Enter its rate by hand. A rate that moves more than 50% from the last automatic rate in one update is rejected, with a message such as Rejected: a 64% change in one update looks wrong. The plugixa_multi_currency_rates_updated action runs with these lines. The route answers 200 even when every source failed: read status and message.
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 POST "https://your-store.example/wp-json/plugixa-multi-currency/v1/rates/update" \
-u "$WP_USER:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-multi-currency/v1/rates/update');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
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/rates/update', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
},
});
const { data } = await response.json();
Quick Links
Share