PDF Product Vouchers
Selling gift vouchers? Need to export voucher numbers, values, and recipient details?
Standard WooCommerce exports only show the product name. Not the actual voucher info.
Here’s how to pull everything from PDF Product Vouchers plugin.
What this code exports
Adds six new columns to your product export:
- Voucher Number
- Voucher Value
- Voucher Value (+Tax)
- Recipient Name
- Message
- Voucher Expiration Date
The complete code
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
// Export product "Vouchers" class WOE_Product_Vouchers { function __construct() { // add new fields add_filter('woe_get_order_product_fields', function ($fields,$format) { $fields['voucher_number'] = array( 'label' => 'Voucher Number', 'colname' => 'Voucher Number', 'checked' => 1 ); $fields['voucher_value'] = array( 'label' => 'Voucher Value', 'colname' => 'Voucher Value', 'checked' => 1); $fields['voucher_value_incl_tax'] = array( 'label' => 'Voucher Value (+Tax)', 'colname' => 'Voucher Value(+Tax)', 'checked' => 1); $fields['voucher_recipient_name'] = array( 'label' => 'Recipient Name', 'colname' => 'Recipient Name', 'checked' => 1 ); $fields['voucher_message'] = array( 'label' => 'Message', 'colname' => 'Message', 'checked' => 1 ); $fields['voucher_expiration_date'] = array( 'label' => 'Voucher Expiration Date', 'colname' => 'Voucher Expiration Date', 'checked' => 1); return $fields; }, 10, 2); // get voucher for item add_action( "woe_get_order_product_item", function ($item) { $this->voucher = false; $voucher_meta = $item->get_meta( '_voucher_id', true); if( $voucher_meta ) $this->voucher = wc_pdf_product_vouchers_get_voucher( $voucher_meta ); }); // just return fields add_filter('woe_get_order_product_value_voucher_number', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_voucher_number(); return $value; }, 10, 4); add_filter('woe_get_order_product_value_voucher_value', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_voucher_value(); return $value; }, 10, 4); add_filter('woe_get_order_product_value_voucher_value_incl_tax', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_voucher_value_incl_tax(); return $value; }, 10, 4); add_filter('woe_get_order_product_value_voucher_recipient_name', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_recipient_name(); return $value; }, 10, 4); add_filter('woe_get_order_product_value_voucher_message', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_message(); return $value; }, 10, 4); add_filter('woe_get_order_product_value_voucher_expiration_date', function ($value,$order, $item, $product) { if( $this->voucher ) $value = $this->voucher->get_expiration_date(); return $value; }, 10, 4); } } new WOE_Product_Vouchers(); |
Setup steps
- Copy the entire code block
- Paste into your theme’s
functions.php - Go to Advanced Order Export for WooCommerce
- Create or edit an export profile
- Open Setup Fields → Products
- You’ll see six new voucher fields. Check the ones you need
- Save and run a test export
What your export looks like
| Order | Product | Voucher Number | Voucher Value | Recipient Name | Message | Expiration Date |
|---|---|---|---|---|---|---|
| #1001 | Gift Card | VC-1234-ABCD | $50.00 | Sarah Johnson | Happy Birthday! | 2026-12-31 |
| #1002 | Gift Card | VC-5678-EFGH | $100.00 | Mike Chen | Congrats! | 2026-12-31 |
When you need this
You sell gift vouchers. Need to track which voucher number went to which customer.
Your accounting team needs voucher values with and without tax.
You offer personalized messages. Need to verify content before printing.
You manage expiration dates. Need to report on soon-to-expire vouchers.
Common mistake
The code expects the PDF Product Vouchers plugin to be active. Function wc_pdf_product_vouchers_get_voucher() must exist.
No voucher data? Check that vouchers were actually generated. Sometimes vouchers create after payment completes.
Empty columns?
Three things to verify:
- Is PDF Product Vouchers installed and active?
- Does the order contain a voucher product?
- Has the voucher been generated (not just added to cart)?
Run a test order. Buy a voucher. Complete checkout. Then export.
Pro tip
Need only vouchers in your export? Filter by product type. Exclude regular products.
Add the Expiration Date column. Sort by it. See which vouchers expire soon.
Real talk
PDF Product Vouchers stores voucher data in a custom post type. Not in standard order item meta.
This code finds the voucher ID from order item meta. Then loads the full voucher object. Then pulls each field.
Works with both free and Pro versions of PDF Product Vouchers.
Your gift card team finally gets all voucher details in one export. No more manual lookups.