The introduction of custom placeholders on WooCommerce invoices, packing slips and credit notes proves to be essential for business communication, branding, and operational efficiency. The default templates may not always include all necessary information relevant to your business or customers, such as custom messages, additional order details, or special handling instructions. With WebToffee’s WooCommerce PDF Invoices, Packing Slips, and Credit Notes plugin, store owners can dynamically insert personalized data into invoices, packing slips and credit notes enhancing clarity, professionalism, and customer experience.
Here are the brief steps in adding custom placeholders:
- Add the custom code snippet to your WordPress site.
- Insert the custom placeholder in the template.
- Save 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 your WordPress site.
Before adding the code, ensure you update the custom code snippet by replacing ‘_metakey1’
and ‘_metakey2’
with the appropriate meta keys for the data you want to display on the document.
You can 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 this article: Adding Custom Codes Using Third-Party Plugins.
Note: To add custom placeholders to packing slips, credit notes and delivery notes, update ($template_type==’invoice’
) in the code to ($template_type==’packinglist’
) for packing slips or ('creditnote' === $template_type
) for credit notes or ($template_type==’deliverynote’
) for delivery notes.
Step 2: Add the custom placeholders to the template
After adding the custom code snippet, next step is to insert the custom placeholder in the document template.
- First, copy the two placeholders
[wfte_custommeta1]
and[wfte_custommeta2]
from the custom code snippet. - Navigate to Invoice/Packing > Invoice (Packing slip or credit note) > Customize from the WordPress dashboard.
- Scroll down and click on the Code editor.
- Paste the placeholders into the template code editor. Their placement within the editor will determine their position in the final document.
Step 3: Save Settings
- Click on Update Template to save the changes.
Example
Let’s take an example where we add two custom meta fields – Shipping City and Order Currency—to WooCommerce invoices, packing slips, and credit notes. In the custom code, the meta keys _metakey1
and _metakey2
will be replaced with _shipping_city
and _order_currency
, respectively. These placeholders will then be inserted into the code editor of invoices, packing slips, and credit notes. The placeholders are positioned right below the “From Address” placeholder in the document. The meta fields will appear in WooCommerce invoices, packing slips and credit notes as shown below:
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' )