Change the document title

Professional Extension #

If you own a license of the Professional extension or our PDF Invoice extensions bundle, you can change the title of the document simply via the plugin settings.

Path: WooCommerce > PDF Invoices > Documents > (document of your choice) > General.

An image of plugin settings

Free version #

If you want to change the title of the Invoice or Packing Slip in the free version, you can do this by filtering the title. You could also create a custom template and simply edit the title manually, but if the document title is the only thing you’re changing, than using the filter is a better option because your template will always be up to date.

You can use the following filter:

HookDescriptionArguments
wpo_wcpdf_document_titleFilter the title of the PDF documentstring $title, object $document

New to using filters? Read this first: How to use filters

Important Note #

If using the Professional extension and the Document title setting (shown above) is used in combination with code snippets (custom code), the priority of the code snippet must be increased to a higher number, like 99. A higher number allows the code snippet to be executed even later, making sure that the execution is happening after the plugin reads the Document title setting.

Example 1: Change “Invoice” to “Tax Invoice” #

Add the following to your themes functions.php (read this if you haven’t edited that file before!):

add_filter( 'wpo_wcpdf_document_title', 'wpo_wcpdf_invoice_title', 10, 2 );
function wpo_wcpdf_invoice_title( $title, $document ) {
	if ( 'invoice' === $document->get_type() ) {
		$title = 'Tax Invoice';	
	}
	return $title;
}

Example 2: Change “Packing Slip” to “Delivery Note” #

add_filter( 'wpo_wcpdf_document_title', 'wpo_wcpdf_packing_slip_title', 10, 2 );
function wpo_wcpdf_packing_slip_title( $title, $document ) {
	if ( 'packing-slip' === $document->get_type() ) {
		$title = 'Delivery Note';	
	}
	return $title;
}

An alternative method that is also update proof, is by using custom translations. You can then also easily modify the filename. Even if your site is in English, you could still use a custom ‘translation’, by using en_GB or en_US, depending on your specific WordPress settings.

You can also use the plugin Say What? to make specific replacements. Make sure to use the exact original (English) string, including capitals, and the text domain woocommerce-pdf-invoices-packing-slips.