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.
- Install and activate the basic plugin WooCommerce PDF Invoices, Packing Slips, Delivery Notes, and Shipping Labels.
- 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. Refer to this article for more details on how to add a custom code snippet using a third-party plugin.
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:
- First, copy the two placeholders [wfte_custommeta1] and [wfte_custommeta2] from the custom code.
- 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.
- 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.
- Now click on Save to reflect the changes.
Let’s take an example of displaying two metadata ‘shipping city‘ and ‘order currency’ using custom placeholders.
- First, replace ‘_metakey1’ and ‘_metakey2’ in the custom code with the metakeys of the shipping city and order currency.
- Now, add the updated custom code snippet to the WordPress site.
- 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.