Contents
On this page
Apply Mass Action - Plugixa Car Parking
POST /plugixa-car-parking/v1/mass-action/{entity_type}
Apply one change to many records of the same kind at once: set the same values on each of them, or move them all to the trash.
The user needs the plugixa_carparking_edit capability for an update, or plugixa_carparking_delete for a delete. The permission is asked again for every record, so a record the user may not touch is skipped and the rest are still processed.
Request
POST https://your-site.example/wp-json/plugixa-car-parking/v1/mass-action/booking
Path parameters
| Name | Type | Description |
|---|---|---|
entity_type |
string |
The kind of record, in its singular form with underscores: booking, location, location_space, space_type, coupon, booking_form, and with Plugixa Car Parking Pro booking_extra, tax_rate, pricing_rule and customer_group. Payments cannot be changed in bulk. |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
action |
string |
Yes | update or delete. |
ids |
integer[] |
Yes | The records to act on. Duplicates and values that are not positive whole numbers are dropped. At most 200 after that. |
values |
object |
For update |
The fields to set on every record. Each record is saved through the same rules as that resource’s Update endpoint, for example Update Booking. |
A delete moves the records to the trash; nothing is deleted permanently. The records are processed one after another, not as one transaction: a failure part way through leaves the records before it changed.
{
"action": "update",
"ids": [12, 13, 14],
"values": { "status": "confirmed" }
}
Responses
200 OK. data counts what happened to each record.
{
"success": true,
"data": {
"done": 2,
"skipped": 1,
"failed": 0
}
}
| Field | Type | Meaning |
|---|---|---|
data.done |
integer |
Records changed or trashed |
data.skipped |
integer |
Records that do not exist, or that the user may not touch |
data.failed |
integer |
Records whose save or trash was refused, for example a value that failed validation, or a location that upcoming bookings still use |
Note. A
200does not mean every record changed. Checkskippedandfailed: the reason a record failed is not reported, so repeat the change on that record through its own Update or Delete endpoint to see the error.
Errors
| Status | Code | When |
|---|---|---|
401 / 403 |
plugixa_carparking_forbidden |
entity_type is not one of the kinds listed above, or the user lacks the capability for action. |
422 |
plugixa_carparking_invalid_action |
action is not update or delete. |
400 |
plugixa_carparking_nothing_selected |
ids holds no usable id. |
422 |
plugixa_carparking_too_many |
More than 200 ids. |
422 |
plugixa_carparking_nothing_to_change |
action is update and values is missing or empty. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-car-parking/v1/mass-action/booking" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"action":"update","ids":[12,13,14],"values":{"status":"confirmed"}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-parking/v1/mass-action/booking');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'action' => 'update',
'ids' => [12, 13, 14],
'values' => ['status' => 'confirmed'],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-car-parking/v1/mass-action/booking', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({ action: 'update', ids: [12, 13, 14], values: { status: 'confirmed' } }),
});
const { data } = await response.json();
Quick Links
Share