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:
- Add the custom code snippet to your WordPress site.
- Add the custom placeholders to the template.
- Save the Settings.
Prerequisites
- Install and activate the free WooCommerce PDF Invoices, Packing Slips, Delivery Notes, and Shipping Labels plugin.
- 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:
- First, copy the two placeholders
[wfte_custommeta1]
and[wfte_custommeta2]
from the custom code snippet. - Navigate to the Code editor of the active invoice template.
- Navigate to Invoice/Packing > Invoice > Customize from the WordPress dashboard.
- Under the Customize tab, head to the Code editor.
- 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.
Step 3: Save the Settings
- 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.
- Replace ‘
_metakey1’
and ‘_metakey2
’ in the custom code with the meta keys of shipping city and order currency (_shipping_city
and_order_currency
, respectively). - Add the updated custom code snippet to the WordPress site.
- Paste the two custom placeholders into the invoice template’s HTML code.
- Save the settings.
The WooCommerce invoice document, containing the two custom placeholders, will look like this.
Discover More:
Max
October 19, 2023
Doesn’t work, the code creates a critical error
Hema
October 19, 2023
Hello Max,
Thanks for reaching out.
From the given data, the issue that is causing the error is not very clear. Kindly contact customer support for further assistance.
James Edwards
October 22, 2021
How do you find the customer note? What’s the meta?
Mike
October 26, 2021
Hi James,
Thanks for reaching out. You can use the placeholder [wfte_customer_note] to your active template HTML to show the customer note.
Santiago Rocha
December 16, 2020
Hello, how can I add custom fields at product detail level? I need to replace the price with a pre calculated retail price in a meta custom field under products.
Mark
December 16, 2020
It would require some filters to do so. Please contact us via the support forum.
MUDIT
August 26, 2020
How can I copy the place holders in the template HTML code?
Mark
August 26, 2020
Go to whichever label settings that you want to add then open the Customize tab > Code menu.
Theo moulos
June 22, 2020
and if I want invoice and deliverynote?
Mark
June 22, 2020
Please update below line in code:
if($template_type=='invoice' || $template_type=='deliverynote' )