---
title: "PDF Invoices & Packing Slips: Developer Hooks and Filters Reference"
description: "Developer reference for WooCommerce PDF invoices: value, item-loop and numbering filters, and actions."
url: "https://wpfactory.com/docs/pdf-invoicing-developer-hooks-filters/"
updated: "2026-09-26"
category: Developers
---

# PDF Invoices & Packing Slips: Developer Hooks and Filters Reference

## Developer hooks and filters reference

[PDF Invoices & Packing Slips Generator for WooCommerce](https://wpfactory.com/item/pdf-invoicing-for-woocommerce/) exposes a set of filters and actions so you can adjust document data, numbering, and behavior in code without editing plugin files. Every hook below is verified against the plugin source (v2.4.8). All hooks use the `alg_wc_pdf_invoicing_` prefix.

### Value filters

| Filter | Filtered value | Arguments |
| --- | --- | --- |
| `alg_wc_pdf_invoicing_return_prop` | The value any property shortcode is about to return. | `$value, $atts, $shortcodes_obj` |
| `alg_wc_pdf_invoicing_get_doc_option` | Any document option value read by the plugin. | `$value, $doc_id, $option_id` |
| `alg_wc_pdf_invoicing_get_html_content` | The document's rendered HTML content, after content filters. | `$content, $doc` |
| `alg_wc_pdf_invoicing_default_doc_title` | The default title of a document (for example "Invoice"). | `$title, $doc_id` |
| `alg_wc_pdf_invoicing_enabled_docs` | The array of enabled document IDs the plugin processes. | `$docs` |
| `alg_wc_pdf_invoicing_create_docs` | Whether a document should be auto-created for an order (return `false` to skip). | `$do_create, $doc_id, $order_id` |
| `alg_wc_pdf_invoicing_add_order_notes` | Whether an order note is added when a document is created or removed (default `true`). | `$add_note` |
| `alg_wc_pdf_invoicing_counters_settings` | The Counters settings-section array. | `$settings` |

#### Override a document option, for example the number format

```
add_filter( 'alg_wc_pdf_invoicing_get_doc_option', function ( $value, $doc_id, $option_id ) {
    if ( 0 === (int) $doc_id && 'number_format' === $option_id ) {
        $value = 'INV-[current_time datetime_format="Y"]-[doc_counter format="%05d"]';
    }
    return $value;
}, 10, 3 );
```

#### Skip automatic creation for zero-total orders

```
add_filter( 'alg_wc_pdf_invoicing_create_docs', function ( $do_create, $doc_id, $order_id ) {
    $order = wc_get_order( $order_id );
    return ( $order && 0 == $order->get_total() ) ? false : $do_create;
}, 10, 3 );
```

### Item-loop filters

These fire inside the `[each_item]` shortcode, so you can reorder, filter, or wrap line items.

| Filter | Filtered value | Arguments |
| --- | --- | --- |
| `alg_wc_pdf_invoicing_shortcode_each_item_items` | The list of order items iterated by `[each_item]`. | `$items, $order, $shortcodes_obj` |
| `alg_wc_pdf_invoicing_shortcode_each_item_before_item` | Output accumulated before each item is rendered. | `$output, $item, $order, $shortcodes_obj` |
| `alg_wc_pdf_invoicing_shortcode_each_item_after_item` | Output accumulated after each item is rendered. | `$output, $item, $order, $shortcodes_obj` |

#### Sort invoice line items alphabetically by name

```
add_filter( 'alg_wc_pdf_invoicing_shortcode_each_item_items', function ( $items, $order, $obj ) {
    uasort( $items, function ( $a, $b ) {
        return strcmp( $a->get_name(), $b->get_name() );
    } );
    return $items;
}, 10, 3 );
```

### Actions

| Action | Fires when | Arguments |
| --- | --- | --- |
| `alg_wc_pdf_invoicing_doc_created` | After a document is created for an order. | `$order_id, $doc` |
| `alg_wc_pdf_invoicing_doc_removed` | After a document is removed from an order. | `$order_id, $doc` |
| `alg_wc_pdf_invoicing_before_core_loaded` | Just before the plugin core loads. | `$core` |
| `alg_wc_pdf_invoicing_admin_doc_settings_loaded` | After the document settings sections are registered in the admin. | `$settings_page` |

#### Log every document number as it is created

```
add_action( 'alg_wc_pdf_invoicing_doc_created', function ( $order_id, $doc ) {
    error_log( 'Created ' . $doc->get_number() . ' for order ' . $order_id );
}, 10, 2 );
```

### The settings gate filter

`alg_wc_pdf_invoicing_settings` is an internal filter the plugin uses to gate Pro-only behavior (for example, whether the **Total documents** field is read-only). In the free version it returns the passed default; in Pro it returns an empty value or an unlocking array. It is not intended for store customization.

### Useful objects

The `$doc` object passed to the actions is an `Alg_WC_PDF_Invoicing_Doc` instance. Handy methods include `get_number()`, `get_counter()`, `get_formatted_date()`, `get_author_full_name()`, `is_created()`, and `get_pdf( $dest, $path )`. The shortcodes object passed to `alg_wc_pdf_invoicing_return_prop` exposes `get_current_language_for_translate()` for language-aware output.

### Need help?

If you are extending [PDF Invoices & Packing Slips Generator for WooCommerce](https://wpfactory.com/item/pdf-invoicing-for-woocommerce/) and a hook does not behave as expected, contact us on the [PDF Invoicing support forum](https://wpfactory.com/support/item/pdf-invoicing-for-woocommerce/) with the hook name and a short code sample.

Related articles

- [Getting Started with PDF Invoices & Packing Slips for WooCommerce](https://wpfactory.com/docs/introduction-and-overview-for-pdf-invoices-plugin/)
- [PDF Invoice Shortcode Attributes and Placeholders Reference](https://wpfactory.com/docs/pdf-invoice-shortcode-attributes-reference/)
- [Let Customers Download PDF Invoices from My Account](https://wpfactory.com/docs/woocommerce-pdf-invoices-my-account/)
- [How to Add a Page Background or Watermark to PDF Invoices](https://wpfactory.com/docs/pdf-page-background-and-watermark/)
- [How to Add Multiple Document Types (Packing Slip, Credit Note)](https://wpfactory.com/docs/multiple-pdf-document-types/)
