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

Adding Custom Filename to WooCommerce Invoices

Last updated on December 7, 2023

Custom filenames for invoice documents make it easier to find and identify specific invoices, which is especially useful for businesses with many transactions. The WebToffee’s free WooCommerce PDF Invoices, Packing Slips, Delivery Notes, and Shipping Labels 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. Choosing a filename format for Invoice PDF documents.
  2. Adding a custom prefix to the filename. Store owners can add a custom prefix in two ways:
    1. Using the Custom PDF name prefix option.
    2. Using a custom code snippet.

Choosing 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.
  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
  1. Click on Update Settings and save changes.

Adding a custom prefix to the filename

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. From the Others section, navigate to the Custom PDF name prefix option.
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
  1. Click on Update Settings and save 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. To know more about how to add a custom code snippet using a third-party plugin, refer to this article.

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.