Documentation/Print Invoice, Packing Slip, Delivery Note & Label for WooCommerce/Use of predefined filters in WooCommerce documents

Use of predefined filters in WooCommerce documents

WooCommerce PDF Invoices, Packing Slips, Delivery Notes & Shipping Label plugin handles all e-commerce document requirements. It consists of specific settings to configure the document types according to your desired functionality. You can even customize each document layout and append necessary details into it.

Apart from existing features, the plugin also provides additional filters to extend plugins’ functionality. Insert the common info used across all the documents in the General settings window.

In order to get access to these filters, first of all, install and activate the plugin.

Filters

Navigate to the Invoice/Packing >General settings of the plugin from the WooCommerce dashboard. It consists of a Help Guide tab which is further classified into Help Links and Filters.

Help links will take you directly to the documentation and support. The Filters will list out various code snippets that help to extend the underlying plugin functionality.

WooCommerce Invoice or Packing Slip-Help-Filter List
WooCommerce Invoice or Packing Slip-Help-Filter List

You can expand a filter to get its code snippet, copy the code and paste it in the functions.php of your active child theme.

Using a filter

For example, to change the default appearance of the order date in the invoice, you can use the filter Alter order date.  You can simply copy the corresponding code snippet by expanding the filter as shown below:

WooCommerce Invoice or Packing Slip-Alter Order Date Filters
WooCommerce Invoice or Packing Slip-Alter Order Date Filters

Next, you will have to paste the code into the function.php file.

Place a filter within the concerned function enclosed in parenthesis with an adequate number of arguments. In the above example, wf_pklist_alter_order_date is the filter name and wt_pklist_change_order_date_format is the function name.  Also, the return date format is specified as “Y-m-d” which means the order date will be displayed as Date:2019-09-26. However, you can insert the values accordingly to get your desired style. The date format “Y-M-d” displays the order date as Date:2019-Sep-26 in the documents.

Know more about date constants, refer to the article.

  • Was this article helpful?
  • YesNo