Contents
On this page
Void Voucher - Plugixa PDF Vouchers for WooCommerce
POST /plugixa-pdf-vouchers/v1/vouchers/{id}/void
Cancel a voucher, like Void voucher on the voucher page. What was left on it is written off with a void line, its status becomes void and the code stops working. This cannot be undone.
Needs a user with the plugixa_pdfv_delete capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators and shop managers get it when the plugin is activated; see Staff access.
Request
POST https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/vouchers/95/void
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The voucher’s id |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
note |
string |
No | The reason, kept in the history. The admin screen asks for one; the endpoint does not insist. |
{
"note": "Code posted on a public forum"
}
Responses
200 OK. data is the voucher with its history, as in Get Voucher, now with status void and balance 0.
Errors
| Status | Code | When |
|---|---|---|
401 / 403 |
plugixa_pdfv_forbidden |
The caller lacks the capability. |
404 |
plugixa_pdfv_not_found |
No voucher with that id. |
Plus the errors every endpoint can return.
A voucher that was already used up has nothing to write off: its status still becomes void, but no void line is added (and the Pro voucher.voided webhook does not fire).
Examples
curl -s -X POST "https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/vouchers/95/void" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"note":"Code posted on a public forum"}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/vouchers/95/void');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'note' => 'Code posted on a public forum',
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/vouchers/95/void', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ note: 'Code posted on a public forum' }),
});
const { data } = await response.json();
Quick Links
Share