WooCommerce PDF Invoices & Packing Slips
Need to track credit notes? Refund numbers and dates in your exports?
The PDF Invoices & Packing Slips plugin creates credit notes for refunds. Standard exports ignore them.
Here’s how to pull credit note details into your order export.
What this code exports
Adds three credit note columns:
- Credit Note Number
- Credit Note Date (raw format)
- Formatted Credit Note Date (readable format)
If an order has multiple refunds, the code takes the first one.
The complete code
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// add Credit Note details add_filter('woe_get_order_fields', 'woe_add_order_fields'); function woe_add_order_fields($fields) { $fields['credit_note_number'] = array( 'label' => 'Credit Note Number', 'colname' => 'Credit Note Number', 'checked' => 1 ); $fields['credit_note_date'] = array( 'label' => 'Credit Note Date', 'colname' => 'Credit Note Date', 'checked' => 1 ); $fields['credit_note_date_formatted'] = array( 'label' => 'Formatted Credit Note Date', 'colname' => 'Formatted Credit Note Date', 'checked' => 1 ); return $fields; } add_filter('woe_get_order_value_credit_note_number', 'woe_get_credit_note_field', 10, 3); add_filter('woe_get_order_value_credit_note_date', 'woe_get_credit_note_field', 10, 3); add_filter('woe_get_order_value_credit_note_date_formatted', 'woe_get_credit_note_field', 10, 3); function woe_get_credit_note_field($value,$order, $field) { $refunds = $order->get_refunds(); if ( !empty( $refunds ) ) // take 1st! $value = get_post_meta( $refunds[0]->id, '_wcpdf_'.$field, true); return $value; } |
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 → Others
- You’ll see credit note fields. Check the ones you need
- Save and test on an order with a refund
What your export looks like
| Order # | Order Total | Refund Amount | Credit Note Number | Credit Note Date | Formatted Credit Note Date |
|---|---|---|---|---|---|
| 1001 | $150.00 | $50.00 | CN-2026-00123 | 2026-05-15 | May 15, 2026 |
| 1002 | $89.00 | $89.00 | CN-2026-00124 | 2026-05-16 | May 16, 2026 |
When you need this
You issue refunds. Need to track credit note numbers for accounting.
Your finance team needs credit note dates for reconciliation.
You run reports on refunds by period.
You integrate with external accounting software. Need credit note references.
How it works
When you refund an order, PDF Invoices & Packing Slips creates a credit note. Stores it as a post meta on the refund object.
The code finds the first refund on the order. Pulls the credit note number and dates. Puts them in your export.
Multiple refunds?
The code only takes the first refund. Most orders have one refund.
Need all refunds? Modify the loop. Join multiple credit note numbers with commas.
Empty columns?
No refund on this order. Or refund happened outside PDF Invoices plugin.
Credit notes only exist if you generated them through the plugin.
Common mistake
The code uses _wcpdf_credit_note_number, _wcpdf_credit_note_date, and _wcpdf_credit_note_date_formatted as meta keys.
If your plugin version uses different keys, the export will be empty. Check your database for the correct meta keys.
Pro tip
Need the credit note URL? Add another field:
|
1 |
$fields['credit_note_url'] = array('label' => 'Credit Note URL', 'colname' => 'Credit Note URL', 'checked' => 1); |
Then in the woe_get_credit_note_field function, add a case for credit_note_url.
Real talk
PDF Invoices & Packing Slips is one of the most popular WooCommerce plugins. But its credit note data isn’t automatically exportable.
This code bridges that gap. Your accounting team gets clean credit note references.
No more manual entry of refund numbers. Export once. Reconcile directly.