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 September 18, 2024

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.

Here are the brief steps:

  1. Add the custom code snippet to your WordPress site.
  2. Add the custom placeholders to the template.
  3. Save the Settings.

Prerequisites

  1. Install and activate the free WooCommerce PDF Invoices, Packing Slips, Delivery Notes, and Shipping Labels plugin.
  2. Install and activate the pro add-on WooCommerce PDF Invoices, Packing Slips, and Credit Notes.

Step 1: Add the custom code snippet

The first step is to add the custom code snippet to the WordPress site. To do this, add the snippet to the active child theme’s functions.php file or use a third-party plugin. To learn more about adding a custom code snippet using a third-party plugin, refer to the following article: Adding Custom Codes Using Third-Party Plugins.

In the custom code snippet, replace ‘_metakey1’ and ‘_metakey2’ with the meta keys of the data you wish to display on the invoice.

Note: To add custom placeholders to packing slips or delivery notes, update ($template_type==’invoice’) in the code to ($template_type==’packinglist’) for packing slips and ($template_type==’deliverynote’) for delivery notes.

Step 2: Add the custom placeholders to the template

Add the two custom placeholders to the invoice template’s HTML code. To achieve this, follow the steps below:

  1. First, copy the two placeholders [wfte_custommeta1] and [wfte_custommeta2] from the custom code snippet.
  2. Navigate to the Code editor of the active invoice template.
    1. Navigate to Invoice/Packing > Invoice > Customize from the WordPress dashboard.
    2. Under the Customize tab, head to the Code editor.
Image highlighting the Code editor
Image highlighting the Code Editor
  1. Paste the placeholders within the code editor of the invoice template.
    • The position of the custom placeholders in the code editor determines its position in the invoice document.
Adding the placeholders in the HTML code editor
Adding the placeholders in the HTML code editor

Step 3: Save the Settings

  1. Click Save/Save and activate to save the changes and activate the existing template.

    Use case

    Let’s add two metadata, ‘shipping city’ and ‘order currency,’ to the invoice document.

    1. Replace ‘_metakey1’ and ‘_metakey2’ in the custom code with the meta keys of shipping city and order currency ( _shipping_city and _order_currency, respectively).
    2. Add the updated custom code snippet to the WordPress site.
    3. Paste the two custom placeholders into the invoice template’s HTML code.
    4. Save the settings.

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

    WooCommerce Invoice with custom placeholders
    WooCommerce Invoice with custom placeholders