Contents
On this page

Reorder Locations - Plugixa Chauffeur

POST /plugixa-chauffeur/v1/locations/reorder

Set the display order of several locations in one call.

Needs a signed-in user with the plugixa_chauffeur_manage capability (administrators have it after activation).

Request

POST https://your-site.example/wp-json/plugixa-chauffeur/v1/locations/reorder

Request body

Content type: application/json

Field Type Required Description
items array Yes A list of { "id", "display_order" } objects. Must not be empty.
items[].id integer Yes The row to move.
items[].display_order integer Yes Its new position. Lower comes first.

Each row in items is updated on its own. Rows you leave out keep their position, and an id that does not exist is skipped without an error.

{
  "items": [
    {
      "id": 3,
      "display_order": 0
    },
    {
      "id": 1,
      "display_order": 1
    },
    {
      "id": 2,
      "display_order": 2
    }
  ]
}

Responses

200 Saved. data is null.

{
  "success": true,
  "message": "Order updated.",
  "data": null
}

Errors

Status Code When
400 rest_error items is missing or empty (“Items are required.”).

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-chauffeur/v1/locations/reorder" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"items":[{"id":3,"display_order":0},{"id":1,"display_order":1},{"id":2,"display_order":2}]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-chauffeur/v1/locations/reorder');
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([
        'items' => [
            [
                'id'            => 3,
                'display_order' => 0,
            ],
            [
                'id'            => 1,
                'display_order' => 1,
            ],
            [
                'id'            => 2,
                'display_order' => 2,
            ],
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = Buffer.from(`admin:${process.env.WP_APP_PASSWORD}`).toString('base64');
const response = await fetch('https://your-site.example/wp-json/plugixa-chauffeur/v1/locations/reorder', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    items: [
      { id: 3, display_order: 0 },
      { id: 1, display_order: 1 },
      { id: 2, display_order: 2 },
    ],
  }),
});
const { data } = await response.json();

Quick Links

Share