Contents
On this page
Save Fixed Prices - Plugixa Multi Currency for WooCommerce
PUT /plugixa-multi-currency/v1/pro/prices/grid
Save prices typed on the Fixed prices screen: one change per product and currency. 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. The user also needs WooCommerce’s edit_products, because these routes change product prices. Each product is also checked with edit_post.
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/prices/grid
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
changes |
object[] |
Yes | Up to 500 changes. More are ignored. |
changes[].id |
integer |
Yes | A simple product or a variation. Not a variable product: its variations have the prices. |
changes[].currency |
string |
Yes | A currency in your list other than the store currency. |
changes[].regular |
string |
No | The fixed regular price. Empty removes it, and the price is converted again. |
changes[].sale |
string |
No | The fixed sale price, lower than regular. Empty removes it. |
Each change replaces both prices of that product and currency: send regular and sale together. Sale dates per currency are kept.
{
"changes": [
{
"id": 15,
"currency": "EUR",
"regular": "17.90",
"sale": "15.90"
},
{
"id": 23,
"currency": "JPY",
"regular": "2400",
"sale": "1500"
}
]
}
Responses
200 OK, even when some changes were refused.
{
"success": true,
"data": {
"saved": 1,
"errors": [
{
"id": 23,
"currency": "JPY",
"message": "The sale price must be lower than the regular price."
}
]
}
}
| Field | Type | Meaning |
|---|---|---|
saved |
integer |
Products changed |
errors |
object[] |
Each refused change: id, currency, message |
Messages: This product cannot be edited. (not found, a variable product, or no right to edit it), Unknown currency., A price is not a valid number., The sale price must be lower than the regular price.
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/prices/grid" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"changes":[{"id":15,"currency":"EUR","regular":"17.90","sale":"15.90"},{"id":23,"currency":"JPY","regular":"2400","sale":"1500"}]}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/prices/grid');
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([
'changes' => [
[
'id' => 15,
'currency' => 'EUR',
'regular' => '17.90',
'sale' => '15.90',
],
[
'id' => 23,
'currency' => 'JPY',
'regular' => '2400',
'sale' => '1500',
],
],
]),
]);
$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/prices/grid', {
method: 'PUT',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ changes: [{ id: 15, currency: 'EUR', regular: '17.90', sale: '15.90' }, { id: 23, currency: 'JPY', regular: '2400', sale: '1500' }] }),
});
const { data } = await response.json();
Quick Links
Share