Contents
On this page
Update Role Prices - Plugixa Multi Currency for WooCommerce
PUT /plugixa-multi-currency/v1/pro/role-prices
Save the tab. PUT and POST work the same way.
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/role-prices
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
rules |
object[] |
No | Replaces every rule. Each needs role, currency (* for all) and percent, more than -100 and up to 1000. |
fixed_roles |
string[] |
No | Replaces the roles with fixed price fields. |
A rule with an unknown role or currency, an invalid percent, or the same role and currency as an earlier rule is dropped without an error. Send rules: [] to remove them all.
{
"rules": [
{
"role": "wholesale_customer",
"currency": "*",
"percent": "-20"
},
{
"role": "b2b_customer",
"currency": "EUR",
"percent": "-15"
}
],
"fixed_roles": ["wholesale_customer"]
}
Responses
200 OK. data is the tab as saved, as in Get Role Prices.
{
"success": true,
"data": {
"rules": [
{
"role": "wholesale_customer",
"currency": "*",
"percent": "-20"
},
{
"role": "b2b_customer",
"currency": "EUR",
"percent": "-15"
}
],
"roles": {
"administrator": "Administrator",
"editor": "Editor",
"customer": "Customer",
"shop_manager": "Shop manager",
"wholesale_customer": "Wholesale customer",
"b2b_customer": "B2B customer",
"...": "..."
},
"fixed_roles": ["wholesale_customer"]
}
}
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/role-prices" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"rules":[{"role":"wholesale_customer","currency":"*","percent":"-20"},{"role":"b2b_customer","currency":"EUR","percent":"-15"}],"fixed_roles":["wholesale_customer"]}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/role-prices');
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([
'rules' => [
[
'role' => 'wholesale_customer',
'currency' => '*',
'percent' => '-20',
],
[
'role' => 'b2b_customer',
'currency' => 'EUR',
'percent' => '-15',
],
],
'fixed_roles' => ['wholesale_customer'],
]),
]);
$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/role-prices', {
method: 'PUT',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ rules: [{ role: 'wholesale_customer', currency: '*', percent: '-20' }, { role: 'b2b_customer', currency: 'EUR', percent: '-15' }], fixed_roles: ['wholesale_customer'] }),
});
const { data } = await response.json();
Quick Links
Share