Plugixa PDF Vouchers exposes WordPress actions and filters for developers. Put your code in a
small plugin or your theme’s functions.php. All hooks start with plugixa_pdfv_.
Hooks run PHP inside WordPress. To send voucher events to another system over HTTP, use
Webhooks PRO.
Vouchers and money
| Hook |
Type |
Arguments |
When |
plugixa_pdfv_voucher_issued |
action |
$voucher |
A voucher was created and its value recorded. |
plugixa_pdfv_ledger_written |
action |
$id, $voucher_id, $type, $amount |
Any balance movement: issue, topup, hold, release, redeem, refund, adjust, expire, void. Runs inside the database transaction: keep it fast and do not throw. |
plugixa_pdfv_voucher_updated |
action |
$voucher_id |
An admin edited a voucher (recipient, message, expiry). |
plugixa_pdfv_voucher_topped_up |
action |
$voucher_id, $amount, $order |
Pro: a gift card was topped up from a paid order. |
plugixa_pdfv_present_voucher |
filter |
$voucher |
The voucher as the admin API and staff lookups return it. |
// Tell a CRM when a voucher is spent.
add_action( 'plugixa_pdfv_ledger_written', function ( $id, $voucher_id, $type, $amount ) {
if ( 'redeem' === $type ) {
wp_schedule_single_event( time(), 'my_crm_voucher_spent', array( $voucher_id, -$amount ) );
}
}, 10, 4 );
Issuing vouchers from orders
| Hook |
Type |
Arguments |
What it changes |
plugixa_pdfv_issue_data |
filter |
$data, $item, $order |
The voucher data before it is created from an order line (amount, kind, expiry, recipient…). |
plugixa_pdfv_issue_unit_data |
filter |
$data, $item, $index |
The data of one unit of the line, for example a different recipient per voucher. |
plugixa_pdfv_issue_line |
filter |
$handled, $data, $item, $order, $quantity |
Return true to settle a line another way than creating vouchers. Runs on every paid status change, so a handler must be idempotent. |
plugixa_pdfv_taxed_at_sale |
filter |
$taxed, $product |
Whether a voucher product is taxed when sold. Default: product vouchers yes, gift cards no. |
// Every voucher from product 530 expires at the end of next year.
add_filter( 'plugixa_pdfv_issue_data', function ( $data, $item ) {
if ( 530 === (int) $item->get_product_id() ) {
$data['expires_at'] = ( (int) wp_date( 'Y' ) + 1 ) . '-12-31';
unset( $data['expiry_days'] );
}
return $data;
}, 10, 2 );
The product page and gift form
| Hook |
Type |
Arguments |
When |
plugixa_pdfv_product_panel |
action |
$product |
Inside the PDF Voucher product tab: print extra fields. |
plugixa_pdfv_product_save |
action |
$product |
Save your extra product fields (WooCommerce checked the nonce). |
plugixa_pdfv_product_form_before |
action |
$product |
Above the gift form on the product page. |
plugixa_pdfv_product_form_gift_fields |
action |
$product |
Inside the “A gift for someone” part of the form. |
plugixa_pdfv_voucher_form_assets |
action |
$product |
A voucher form is on the page: enqueue your scripts. |
plugixa_pdfv_posted_item_data |
filter |
$data |
Add your posted fields to the cart item’s voucher data (sanitize them here). |
plugixa_pdfv_validate_item_data |
filter |
$passed, $data, $product_id |
Return false and add a notice to refuse the add to cart. |
plugixa_pdfv_order_item_meta |
action |
$item, $data |
Store your data on the order line. |
Checkout and spending
| Hook |
Type |
Arguments |
What it changes |
plugixa_pdfv_voucher_covers |
filter |
$covers, $voucher, $product |
Whether a voucher may pay for a product. |
plugixa_pdfv_exchange_rate |
filter |
$rate, $from, $to |
The rate between a voucher’s currency and the currency paid in, or null. See Multi-currency. |
plugixa_pdfv_currency_factor |
filter |
$factor, $code |
Pro: units of a currency per one unit of the base currency, for another currency switcher. |
plugixa_pdfv_code_guess_limits |
filter |
$limits |
misses per window seconds, and lock seconds. Defaults: 10, 900, 1800. |
plugixa_pdfv_code_guess_locked |
action |
$client_hash |
A visitor was locked for guessing codes (a hash, never the IP). |
plugixa_pdfv_client_ip |
filter |
$ip |
The visitor’s address, for sites behind a proxy or CDN. |
plugixa_pdfv_public_request_captcha |
filter |
$verdict, $request, $action |
Check a CAPTCHA token on the public balance and resend forms. Return false or a WP_Error to refuse. |
plugixa_pdfv_pos_tender |
filter |
$enabled |
Pro: offer Gift voucher as a payment in Plugixa POS. Default false. |
// Allow 20 wrong codes per 15 minutes before locking.
add_filter( 'plugixa_pdfv_code_guess_limits', function ( $limits ) {
$limits['misses'] = 20;
return $limits;
} );
PDFs
| Hook |
Type |
Arguments |
What it changes |
plugixa_pdfv_placeholders |
filter |
$tokens |
Add placeholders to the editor’s list (token => description). |
plugixa_pdfv_pdf_values |
filter |
$values, $voucher |
Give the values of your placeholders. |
plugixa_pdfv_template_for |
filter |
$template, $voucher |
The design a voucher is printed with. |
plugixa_pdfv_template_file |
filter |
$file, $preset |
The template file of a layout, so a theme can override a design. |
plugixa_pdfv_presets |
filter |
$presets |
Add layouts: a name, a palette and a template file. |
plugixa_pdfv_fonts |
filter |
$extra |
Add font families (TrueType files inside uploads). |
plugixa_pdfv_qr_payload |
filter |
$payload, $voucher |
What the QR code holds. Default: the voucher code. |
plugixa_pdfv_pdf_html |
filter |
$html, $voucher, $template |
The final HTML before it becomes a PDF. |
plugixa_pdfv_pdf_css |
filter |
$css, $voucher, $template |
The stylesheet of that HTML. |
// A {gift_wrap} placeholder.
add_filter( 'plugixa_pdfv_placeholders', fn( $t ) => $t + array( 'gift_wrap' => 'Gift wrap note' ) );
add_filter( 'plugixa_pdfv_pdf_values', function ( $values, $voucher ) {
$values['gift_wrap'] = 'Wrapped with love by Maison Willow';
return $values;
}, 10, 2 );
Keep the QR payload the voucher code, or a URL carrying it in a code parameter, so
Scan to redeem can still read it.
Delivery and emails
| Hook |
Type |
Arguments |
When |
plugixa_pdfv_send_voucher |
action |
$voucher_id, $reason |
Trigger a delivery yourself. $reason: order, manual, resend, scheduled or buyer_copy. |
plugixa_pdfv_deliver_now |
filter |
$send, $voucher_id, $reason |
Return false to hold back an email (Pro scheduled delivery uses it). |
plugixa_pdfv_delivering |
action |
$voucher, $reason |
A voucher is being delivered, before the email. Use it to add a channel. |
plugixa_pdfv_email_after_download |
action |
$voucher, $email |
In the voucher email, after the download button. |
plugixa_pdfv_voucher_locale |
filter |
$locale, $voucher |
The language a voucher’s PDF and emails are produced in. |
// Send a voucher again from your own code.
do_action( 'plugixa_pdfv_send_voucher', 412, 'resend' );
My Account
| Hook |
Type |
Arguments |
When |
plugixa_pdfv_account_vouchers |
filter |
$rows, $user |
The vouchers listed for a customer. |
plugixa_pdfv_account_vouchers_before |
action |
$rows, $user |
Above the list. |
plugixa_pdfv_account_vouchers_after |
action |
$rows, $user |
Below the list. |
plugixa_pdfv_account_voucher_links |
action |
$voucher |
Next to Download PDF on one row. |
Permissions and settings
| Hook |
Type |
Arguments |
What it changes |
plugixa_pdfv_user_can |
filter |
$allowed, $action, $entity_type, $record, $user_id |
Every permission decision. See Staff access. |
plugixa_pdfv_capabilities |
filter |
$map |
The capability map the admin app receives (hides controls only). |
plugixa_pdfv_settings_defaults |
filter |
$defaults |
Default settings. |
plugixa_pdfv_settings_saved |
action |
$settings |
After the settings are saved. |
Plugin lifecycle
| Hook |
Type |
When |
plugixa_pdfv_loaded |
action |
The plugin has booted. |
plugixa_pdfv_activated |
action |
The plugin was activated. |
plugixa_pdfv_deactivated |
action |
The plugin was deactivated. |
plugixa_pdfv_uninstall |
action |
During a deleting uninstall, before the tables are dropped. |
Hooks marked Pro exist only when Pro is active.