Contents
On this page
Update PDF Design - Plugixa PDF Vouchers for WooCommerce
PATCH /plugixa-pdf-vouchers/v1/templates/{id}
Change a design. Only the fields you send change.
Needs a user with the plugixa_pdfv_edit 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
PATCH https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/templates/1
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The design’s id |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
No | The design’s name. |
preset |
string |
No | The layout. Unknown values are ignored. Defaults to classic. |
paper |
string |
No | A4, A5 or LETTER. |
orientation |
string |
No | L (default) or P. |
is_default |
boolean |
No | Make it the store default. |
settings |
object |
No | Any of the settings of Get PDF Design. Missing ones keep their value, or the layout’s starting value. A colour that is not hex is ignored. |
layout |
object |
No | Pro: the elements of a drag-and-drop design, checked and cleaned before it is stored. |
{
"settings": {
"subtitle": "Maison Willow · Spa, Tea & Home",
"terms": "Valid in our Paris shop and online."
}
}
Responses
200 OK. data is the design as saved, fields as in Get PDF Design.
Errors
| Status | Code | When |
|---|---|---|
401 / 403 |
plugixa_pdfv_forbidden |
The caller lacks the capability. |
404 |
plugixa_pdfv_not_found |
No design with that id: Design not found. |
Plus the errors every endpoint can return.
Examples
curl -s -X PATCH "https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/templates/1" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"settings":{"subtitle":"Maison Willow · Spa, Tea & Home","terms":"Valid in our Paris shop and online."}}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/templates/1');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'settings' => [
'subtitle' => 'Maison Willow · Spa, Tea & Home',
'terms' => 'Valid in our Paris shop and online.',
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/templates/1', {
method: 'PATCH',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ settings: { subtitle: 'Maison Willow · Spa, Tea & Home', terms: 'Valid in our Paris shop and online.' } }),
});
const { data } = await response.json();
Quick Links
Share