PDF template filter hooks

The template engine of PDF Invoices & Packing slips is built for flexibility, and includes a list of filter hooks that you can use to manipulate different types of data.

Hook Description Arguments
wpo_wcpdf_listing_actions Filter PDF orders listing actions array $listing_actions, object $order
wpo_wcpdf_meta_box_actions Filter meta box actions in single order page array $meta_box_actions, int $post_id
wpo_wcpdf_bulk_actions Filter bulk actions array $actions
wpo_wcpdf_document_classes Filter document classes – used in admin to load settings array $documents
wpo_wcpdf_myaccount_allowed_order_statuses Filter allowed order status array $order_status
wpo_wcpdf_myaccount_button_text Filter my account button text string $button_text, object $invoice
wpo_wcpdf_myaccount_actions Filter my account actions array $actions, object $order
wpo_wcpdf_email_attachment_order Filter email attachment order object $order, object $email, string $document_type
wpo_wcpdf_lock_attachment_file Filter lock attachment file – default true bool
wpo_wcpdf_reuse_attachment_age Filter reuse temp file age – default 60 (seconds) int
wpo_wcpdf_attachment_locked_file_delay Filter optional delay (ms) to double check if the write process is finished – default 250 ms int
wpo_wcpdf_attach_documents Filter attach documents for email array $attach_documents
wpo_wcpdf_custom_attachment_condition Filter custom attachment condition bool = true, object $order, string $email_id, string $document_type
wpo_wcpdf_document_types_for_email Filter document types for email array $document_types, int $email_id, object $order
wpo_wcpdf_check_privs Filter user privileges check bool $allowed, array $order_ids
wpo_wcpdf_tmp_path Filter PDF temp folder bool|string $tmp_base
wpo_wcpdf_before_dompdf_render Filter before DOMPDF render object $dompdf, string $html
wpo_wcpdf_after_dompdf_render Filter after DOMPDF render object $dompdf, string $html
wpo_wcpdf_validate_input Filter settings validate options array $output, array $input
wpo_wcpdf_settings_fields_debug Filter settings fields array $settings_fields, string $page, string $options_group, string $options_name
wpo_wcpdf_template_settings_paper_size Filter template paper size setting array $paper_size
wpo_wcpdf_settings_fields_general Filter settings fields array $settings_fields, string $page, string $options_group, string $options_name
wpo_wcpdf_template_paths Filter template paths array $template_paths
wpo_wcpdf_templates Filter templates array $installed_templates
wpo_wcpdf_settings_tabs Filter settings tabs array $settings_tabs
wpo_wcpdf_output_format Filter output format per document type string $output_format, string $document_type
wpo_wcpdf_process_order_ids Filter order ids array $order_ids, string $document_type
wpo_wcpdf_pdf_maker Filter to change the PDF class (which can wrap another PDF library) string $pdf_maker
wcpdf_disable_deprecation_notices Filter to disable deprecation notices during email sending – default false bool
wcpdf_log_stacktrace Filter to enable/disable log stack trace – default false bool
wpo_wcpdf_address_comparison_fields Filter address fields for billing and shipping address comparison array $address_fields
wpo_wcpdf_ships_to_different_address Billing and shipping addresses are equal, filter to ship to different address bool false, object $order, object $order_document
wpo_wcpdf_billing_address Filter billing address string $billing_address, object $order_document
wpo_wcpdf_billing_email Filter billing email string $billing_email, object $order_document
wpo_wcpdf_billing_phone Filter billing phone string $billing_phone, object $order_document
wpo_wcpdf_shipping_address Filter shipping address string $shipping_address, object $order_document
wpo_wcpdf_shipping_address_fallback Filter shipping address to use fallback if no address – default ‘packing-slip’ string $document_type, object $order_document
wpo_wcpdf_billing_custom_field Filter billing custom field string $custom_field, object $order_document
wpo_wcpdf_date Filter current date string $date, object $order_document
wpo_wcpdf_payment_method Filter payment method string $payment_method, object $order_document
wpo_wcpdf_shipping_method Filter shipping method string $shipping_method, object $order_document
wpo_wcpdf_order_number Filter order number string $order_number, object $order_document
wpo_wcpdf_order_date Filter order date string $date, string $mysql_date, object $order_document
wpo_wcpdf_order_item_data Filter order item data array $data, object $order, string $document_type
wpo_wcpdf_order_items_data Filter order items data array $data_list, object $order, string $document_type
wpo_wcpdf_calculate_tax_rate Filter to enable tax rate calculation – default false bool
wpo_wcpdf_calculate_tax_rate_precision Filter tax rate calculation precision int|bool
wpo_wcpdf_thumbnail_size Filter thumbnail size string $thumbnail_size
wpo_wcpdf_use_path Filter use path bool
wpo_wcpdf_raw_order_totals Filter raw order totals array $order_item_totals, object $order
wpo_wcpdf_woocommerce_totals Filter WooCommerce totals array $totals, object $order, string $document_type
wpo_wcpdf_order_subtotal Filter order subtotal array $subtotal, string $tax, string $discount, object $order_document
wpo_wcpdf_order_shipping Filter order shipping array $shipping, string $tax, object $order_document
wpo_wcpdf_order_discount Filter order discount array $discount, string $type, string $tax, object $order_document
wpo_wcpdf_order_taxes Filter order taxes array $taxes, object $order_document
wpo_wcpdf_order_grand_total Filter order grand total array $grand_total, string $tax, object $order_document
wpo_wcpdf_shipping_notes Filter shipping notes string $shipping_notes, object $order_document
wpo_wcpdf_date_format Filter date format string $date_format, object $order_document
wpo_wcpdf_document_use_historical_settings Filter to use historical settings bool $use_historical_settings, object $order_document
wpo_wcpdf_document_store_settings Filter to use store document settings bool, object $order_document
wpo_wcpdf_non_historical_settings Filter non historical settings array $non_historical_settings
wpo_wcpdf_document_is_enabled Filter if document is enable bool $enabled, string $document_type
wpo_wcpdf_delete_document_data_keys Filter data to remove from document by data keys array $document_data_keys
wpo_wcpdf_document_is_allowed Filter for global prevention of creating specific document bool $allowed, object $order_document
wpo_wcpdf_{$document_slug}_title Filter document title string $title, object $order_document
wpo_wcpdf_document_number_settings Filter document number settings array $number_settings, object $order_document
wpo_wcpdf_template_styles_file Filter templates styles file string $template_styles_file
wpo_wcpdf_template_styles Filter templates styles string|bool $css, object $order_document
wpo_wcpdf_header_logo_id Filter header logo id string $header_logo, object $order_document
wpo_wcpdf_header_logo_img_element Filter header logo img element string $img_element, string $attachment, object $order_document
wpo_wcpdf_{$settings_key} Filter settings text by key (legacy) string $text, object $order_document
wpo_wcpdf_{$settings_key}_settings_text Filter settings text by key string $text, object $order_document
wpo_wcpdf_load_pdf_file_path Allow loading of existing PDF file instead of generating on the fly. string $path, object $order_document
wpo_wcpdf_paper_format Filter document paper format. string $paper_format, string $document_type, object $order_document
wpo_wcpdf_paper_orientation Filter document paper orientation. string $paper_orientation, string $document_type, object $order_document
wpo_wcpdf_get_pdf Filter to get a PDF document. string $pdf, object $order_document
wpo_wcpdf_get_html Filter document HTML. string $html, object $order_document
wpo_wcpdf_filename Filter document filename. string $filename, string $document_type, array $order_ids, string $context
wpo_wcpdf_template_file Filter document template file. string $file_path, string $document_type, object $order
wpo_wcpdf_wc_emails Filter WooCommerce emails. array $emails
wpo_wcpdf_merged_bulk_document_content Filter merged bulk document content. string $html, string $html_content, object $bulk_document
wpo_wcpdf_raw_document_number Filter the raw document number. int $number, array $settings, object $document, object $order
wpo_wcpdf_formatted_document_number Filter the formatted document number. string $formatted_number, object $document_number, string $document_type, int $order_id
wpo_wcpdf_format_document_number Filter on formating the document number. string $formatted_number, object $document_number, object $document, object $order
wpo_wcpdf_{$invoice_slug}_title Filter the invoice document title. string $title, object $document_invoice
wpo_wcpdf_external_invoice_number_enabled Filter to enable third-party generated invoice number. bool, object $document_invoice
wpo_wcpdf_external_invoice_number Filter the third-party generated invoice number. string $invoice_number, object $document_invoice
wpo_wcpdf_document_sequential_number_store Filter the document sequential number store. string $number_store, object $document_invoice
wpo_wcpdf_settings_fields_documents_invoice Filter to alter invoice documents settings fields. array $settings_fields, string $page, string $options_group, string $options_name
wpo_wcpdf_settings_fields_documents_packing_slip Filter to alter packing slip documents settings fields. array $settings_fields, string $page, string $option_group, string $option_name
wpo_wcpdf_number_store_table_name Filter the number store table name. string $table_name, string $store_name, string $method
wpo_wcpdf_invoice_number Filter the invoice number. string $invoice_number, string $order_number, int $order_id, string $mysql_order_date
wpo_wcpdf_invoice_title Filter the invoice title. string $title
wpo_wcpdf_packing_slip_title Filter the packing slip title. string $title
wpo_wcpdf_template_name Filter the template name. string $template_name, string $template_type
wpo_wcpdf_item_row_class Filter the document item row class. int $item_id, string $document_type, object $order, int $item_id


Using filter hooks is not that difficult as it sounds, it’s a simple way for you to manipulate data without dealing with complicated functions or plugin core code. Unlike action hooks, filters always return the first argument data, and because of that you can manipulate that data before returning it. If you never worked with filters you can read this documentation page about how to use filters.

Filter scripts usualy live inside functions.php, a file that comes inside any WordPress theme. You can choose to modify that file directly in the main theme (not recommended), within a child-theme or through a plugin like Code Snippets.

This little snippet will sort the document order items by category.

add_filter( 'wpo_wcpdf_order_items_data', 'wpo_wcpdf_sort_items_by_category', 10, 2 );
function wpo_wcpdf_sort_items_by_category ( $items, $order ) {
	usort($items, function( $a, $b ) {
        return strcmp(wc_get_product_category_list( $a['product']->get_id()), wc_get_product_category_list( $b['product']->get_id()));

    return $items;

This little snippet will hide specific products (indicated by id) from the packing slip document.

add_filter( 'wpo_wcpdf_order_item_data', 'wpo_wcpdf_hide_products_packing_slip', 10, 3 );
function wpo_wcpdf_hide_products_packing_slip( $data, $order, $document_type )
    $products_ids_to_hide = array(16, 23); // include here your product IDs

    if ($document_type == 'packing-slip') { // you can replace with 'invoice' or any other document type

        if( in_array($data['product_id'], $products_ids_to_hide) ) {
            $data['name'] = null;
            $data['quantity'] = null;


    return $data;

This little snippet will disallow a document creation if a specified custom field is found in the order.

add_filter('wpo_wcpdf_document_is_allowed', 'disallow_document_on_custom_field', 10, 2);
function disallow_document_on_custom_field( $allowed, $document )
	$order = $document->order;

	if ( !empty($order) && $document->get_type() == 'custom-template' ) { // replace 'custom-template' with your custom template name or default names like 'invoice', 'packing-slip', etc.

		$order_meta = $order->get_meta('gift_message'); // replace 'gift_message' with you own custom field name

		if( !$order_meta || $order_meta == '' ) {
			$allowed = false;

	return $allowed;