Home > Docs > WooCommerce PDF Invoices, Packing Slips and Credit Notes Plugin > Adding Custom Filenames to WooCommerce Invoices

Adding Custom Filenames to WooCommerce Invoices

Last updated on November 7, 2024

Custom filenames for invoice documents make it easier to find and identify specific invoices, which is especially useful for businesses with many transactions. WebToffee’s WooCommerce PDF Invoices, Packing Slips, and Credit Notes plugin allows store owners to add a custom filename for invoice PDF documents. The plugin allows the store owners to select the desired filename format and add a custom prefix to it. Store owners can do this by following the below steps:

  1. Choose a filename format for invoices.
  2. Add a custom prefix to the filename.
  3. Save the Settings.

Step 1: Choose a filename format for invoice PDF documents

Store owners can choose from the two filename formats provided by the plugin. It can either be [prefix][order_no] or [prefix][invoice_no]. Follow the below steps to choose a filename format for invoice PDF documents:

  1. Navigate to Invoice/Packing > Invoice > General from the WordPress dashboard.
  2. Under the General tab, head to the Others section.
  3. In the Others section, go to the PDF name format option.
Navigating to PDF name format option
Navigating to PDF name format option
  1. Choose the preferred PDF filename format from the dropdown menu.
    • For example, let’s select it as [prefix][invoice_no].
Choosing a PDF name format
Choosing a PDF name format

Step 2: Add a custom prefix to the filename

Custom filename can be added in two ways:

1. Using the Custom PDF name prefix option

The plugin provides store owners with the provision to add a custom prefix of their choice to the filename. The custom prefix will appear along with the order number or the invoice number in the filename. To add a custom prefix to the filename:

  1. Navigate to the Custom PDF name prefix option, from the Others section.
Navigating to the Custom PDF name prefix option
Navigating to the Custom PDF name prefix option
  1. Input a custom prefix in the space provided. (By default the custom prefix for the filename will be Invoice_). Here let’s take an example of adding a custom prefix ‘RECEIPT’.
Custom prefix added
Custom prefix added

Step 3: Save the Settings

  1. Click on Update Settings to save the changes.

Now, the admin generates the invoice PDF document for order #3008 with the invoice number 2. The invoice PDF document with the filename ‘RECEIPT2’ is downloaded as shown below.

Invoice PDF document with custom filename downloaded
Invoice PDF document with custom filename downloaded

2. Using a custom code snippet

Store owners can add custom prefixes to the invoice PDF documents using the custom code snippet given below. This snippet is applicable to both single orders as well as bulk orders. To add a custom prefix using the custom code snippet, follow the below steps:

  1. To add a custom prefix for single orders, replace ‘facture_’ in the custom code snippet with the prefix name of your choice. For bulk orders, replace ‘facture_bulk_’ with the prefix name of your preference.
  2. Upon updation, add the custom code snippet to the WordPress site which is currently in use. Add it to the active child themes functions.php file or use a third-party plugin for the addition. For more details on adding custom code snippets using a third-party plugin, check out the following article: Adding Custom Codes with a Third-Party Plugin.

Note: While using this custom code snippet, the invoice PDF filename will be of the format [prefix][order_no].

Using the invoice number as the filename

Using the custom code snippet given below, store owners can use the invoice number alone as the filename for the invoice PDF documents. To achieve this store owner will have to add the custom code snippet below to the WordPress site in use.