Contents
On this page
Update Role Discounts - Plugixa Extra Product Options
PUT /plugixa-epo/v1/role-discounts
Replace the discounts. Send every role that should keep a discount: roles left out, or sent with 0, get none. Unknown roles are dropped. PATCH and POST work the same.
Needs a user with the plugixa_epo_manage capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators and shop managers hold it; see Permissions. Pro only: on the free plugin this route answers 404 rest_no_route.
Request
PUT https://your-store.example/wp-json/plugixa-epo/v1/role-discounts
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
discounts |
object |
Yes | Role slug => percent off, 0 to 100, up to 2 decimals. |
{
"discounts": {
"wholesale_customer": 20,
"subscriber": 5
}
}
Responses
200 OK. data is as in Get Role Discounts.
{
"success": true,
"data": {
"discounts": {
"wholesale_customer": 20,
"subscriber": 5
},
"roles": [
{
"id": "administrator",
"label": "Administrator"
},
{
"id": "customer",
"label": "Customer"
},
{
"id": "shop_manager",
"label": "Shop manager"
},
{
"id": "wholesale_customer",
"label": "Wholesale customer"
},
{
"id": "subscriber",
"label": "Subscriber"
}
]
}
}
Errors
| Status | Code | When |
|---|---|---|
401 / 403 |
plugixa_epo_forbidden |
The caller lacks the capability: You are not allowed to do that. |
400 |
rest_invalid_param |
A percent is below 0 or above 100. |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-store.example/wp-json/plugixa-epo/v1/role-discounts" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"discounts":{"wholesale_customer":20,"subscriber":5}}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-epo/v1/role-discounts');
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([
'discounts' => [
'wholesale_customer' => 20,
'subscriber' => 5,
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-epo/v1/role-discounts', {
method: 'PUT',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ discounts: { wholesale_customer: 20, subscriber: 5 } }),
});
const { data } = await response.json();
Quick Links
Share