Contents
On this page

Delete Coupon - Plugixa Car Parking

DELETE /plugixa-car-parking/v1/coupons/{id}

Move a coupon to the trash. From then on the code is refused at booking.

The signed-in user needs the plugixa_carparking_delete capability (trash, restore and delete records).

Note. A coupon in the trash still holds its code: a new coupon with the same code is refused with 409 until the trashed one is purged.

Bring it back with POST /coupons/{id}/restore, or delete it for good with DELETE /coupons/{id}/purge: see Trash. Bookings that already used the coupon keep their discount either way.

Request

DELETE https://your-site.example/wp-json/plugixa-car-parking/v1/coupons/5

Path parameters

Name Type Description
id integer The coupon’s id

Responses

200 OK. The coupon is in the trash.

{
  "success": true,
  "data": { "trashed": true }
}
Field Type Meaning
data.trashed boolean Always true on success

Errors

Status Code When
404 plugixa_carparking_not_found No coupon with that id, or it is already in the trash.
409 plugixa_carparking_coupon_in_use An add-on refused it through the plugixa_carparking_coupon_delete_blockers filter. Nothing in 1.2.0 does.

Plus the errors every endpoint can return.

Examples

curl -s -X DELETE "https://your-site.example/wp-json/plugixa-car-parking/v1/coupons/5" \
  -u "admin:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-parking/v1/coupons/5');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'DELETE',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-car-parking/v1/coupons/5', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
  },
});
const { data } = await response.json();

Quick Links

Share