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

Adding Custom Placeholders to WooCommerce Invoices

Last updated on October 9, 2023

By default, WebToffee’s WooCommerce PDF Invoices, Packing Slips, and Credit Notes plugin helps to display metadata using pre-defined placeholders. Adding custom placeholders enables businesses to insert dynamic information, such as customer names, order details, and personalized messages, directly into the invoice. The plugin helps to add custom placeholders to WooCommerce invoices using a custom code snippet. To achieve this add the custom code snippet provided to the WordPress site and then add the custom placeholders into the invoice template’s HTML code.

Prerequisites

  1. Install and activate the free plugin WooCommerce PDF Invoices, Packing Slips, Delivery Notes, and Shipping Labels.
  2. Now as a final prerequisite, install and activate the premium plugin WooCommerce PDF Invoices, Packing Slips, and Credit Notes.

Step 1: Adding the custom code snippet

The first step is to add the custom code snippet to the WordPress site. To do this either add the snippet into the active child theme’s functions.php file or use a third-party plugin. To know more about how to add a custom code snippet using a third-party plugin, refer to this article.

In the custom code snippet below replace ‘_metakey1’ and ‘_metakey2’ with the preferred meta keys.

Step 2: Adding the placeholders

Now add the two custom placeholders into the invoice template’s HTML code. To achieve this follow the basic steps below:

  1. First, copy the two placeholders [wfte_custommeta1] and [wfte_custommeta2] from the custom code.
  2. Now, navigate to the invoice template HTML code.
    • To do this, From the WordPress dashboard, navigate to Invoice/Packing > Invoice.
    • Under the Customize tab, navigate to code.
Navigating to the invoice HTML code
  1. Paste the placeholders in the invoice template HTML code.
    • The position of custom placeholders in the invoice document is based on their position in the invoice template HTML code.
Adding custom placeholders
  1. Now click on Save to reflect the changes.

Example

Let’s take an example of displaying two metadata ‘shipping city‘ and ‘order currency’ using custom placeholders.

  1. First, replace ‘_metakey1’ and ‘_metakey2’ in the custom code with the metakeys of the shipping city and order currency.
  2. Now, add the updated custom code snippet to the WordPress site.
  3. Finally, paste the two custom placeholders into the invoice template HTML code.

The WooCommerce invoice document, containing the two custom placeholders, will look like this.

WooCommerce Invoice with custom placeholders
WooCommerce Invoice with custom placeholders