Contents
On this page

Update Coupon - Plugixa Car Rental

PUT /plugixa-car-rental/v1/coupons/{id}

Change a coupon. Only the fields you send are changed; PATCH works the same way.

Needs the Coupons app on. The user needs the plugixa_car_rental_edit capability.

Request

PUT https://your-site.example/wp-json/plugixa-car-rental/v1/coupons/7

Path parameters

Name Type Description
id integer The coupon’s id

Request body

Content type: application/json

Field Type Required Description
code string No Letters, digits, dashes and underscores: anything else is removed, then it is cut to 50 characters. Must not match another live coupon’s code, ignoring case.
amount number No More than 0. At most 100 for a percentage. Rounded to 2 decimals.
discount_type string No percent or fixed. A fixed discount never takes more than the subtotal.
min_days integer No Shortest rental it applies to. At least 1, the default.
usage_limit integer No Most uses. 0 for no limit.
valid_from string No First day, YYYY-MM-DD, on the site’s calendar. Empty for no start.
valid_until string No Last day, YYYY-MM-DD. On or after valid_from. Empty for no end.
description string No Your note, up to 255 characters.
status string No published or unpublished.
modified_at string No The modified_at you read. When it differs from the stored one the update is refused with 409. See Edit conflicts.

Fields you leave out keep their stored value. The whole coupon, as it would be after the change, is checked again.

{
  "usage_limit": 150,
  "modified_at": "2026-11-12 09:30:00"
}

Responses

200 OK. data is the coupon as it now is.

{
  "success": true,
  "data": {
    "id": 7,
    "code": "WINTER10",
    "code_key": "WINTER10",
    "description": "Winter campaign",
    "discount_type": "percent",
    "amount": 10.0,
    "min_days": 2,
    "valid_from": "2026-12-01",
    "valid_until": "2027-02-28",
    "usage_limit": 150,
    "status": "published",
    "created_by": 1,
    "modified_by": 1,
    "created_at": "2026-11-12 09:30:00",
    "modified_at": "2026-11-12 10:15:00",
    "deleted_at": null,
    "used": 14
  }
}
Field Type Meaning
data.usage_limit integer Most uses, 0 for no limit
data.modified_at string UTC datetime of this change

Errors

Status Code When
404 plugixa_car_rental_not_found No coupon with that id, or it is in the trash.
422 plugixa_car_rental_invalid code is empty after cleaning, amount is not above 0 or a percentage above 100, min_days is below 1, usage_limit is negative, or valid_until is before valid_from. data.field names the field.
409 plugixa_car_rental_invalid Another live coupon already uses this code.
422 plugixa_car_rental_invalid_date valid_from or valid_until is not a date.
422 plugixa_car_rental_invalid_choice status or discount_type is not one of its values. data.allowed lists them.
422 plugixa_car_rental_not_a_number A number field was sent as something else. data.field names it.
422 plugixa_car_rental_negative_number A number field that cannot be negative is. data.field names it.
422 plugixa_car_rental_too_long A text field is longer than its column. data.field names it and data.max gives the limit.
409 plugixa_car_rental_conflict You sent modified_at and the coupon has been saved by someone else since. data.expected and data.current carry both values.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-site.example/wp-json/plugixa-car-rental/v1/coupons/7" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"usage_limit":150,"modified_at":"2026-11-12 09:30:00"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-rental/v1/coupons/7');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS     => json_encode([
        'usage_limit' => 150,
        'modified_at' => '2026-11-12 09:30:00',
    ]),
]);
$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-car-rental/v1/coupons/7', {
  method: 'PUT',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ usage_limit: 150, modified_at: '2026-11-12 09:30:00' }),
});
const { data } = await response.json();

Quick Links

Share