Back to Community

How to Add Custom Data Like Unit Price, Barcodes, and Totals to Your WooCommerce PDF Invoices

Content

Many WooCommerce store owners need to display additional information on their PDF invoices, such as unit prices, product barcodes, or total quantities. This is a common request for accounting clarity, legal compliance, or simply providing a better customer experience. The free 'PDF Invoices & Packing Slips for WooCommerce' plugin has a default structure, but it can be extended to show this extra data.

Why Isn't This Data Shown by Default?

The plugin's free version uses a static template called "Simple." This template is designed to display a standard set of information: product name, quantity, and the line total price. It is not configured to automatically pull and display every possible piece of custom data from your products or orders, as this data can be stored in many different ways by WooCommerce and other plugins.

Common Solutions for Adding Custom Data

1. For Users with PHP Coding Skills (Free Method)

If you are comfortable editing code, you can create a custom PDF template. This involves copying the plugin's template files into your theme and modifying them. This method is powerful but requires maintenance, as custom templates are not automatically updated when the plugin updates.

Example: Adding a Unit Price Column
As seen in the community forums, users have successfully added a unit price column by overriding the template's header and item data functions. This involves using filters like wpo_wcpdf_simple_template_default_table_headers and wpo_wcpdf_order_item_data to insert the unit price data into the invoice table.

2. Identifying Custom Meta Keys

For data like product barcodes or gift card amounts, the first step is always to identify the meta key under which the information is saved in the order. This often requires using a tool to find WooCommerce custom fields. Once you have the correct meta key, you can use code snippets to display this value on the PDF.

3. Using the Premium Templates Extension

For users who prefer a user-friendly, non-code solution, the Premium Templates extension is often suggested. It includes a drag-and-drop customizer tool that allows you to add new columns (like unit price, cost, or barcode) and rearrange the layout of your PDF documents without writing any code. This tool can display product custom fields and other data points easily.

Frequently Asked Questions

Q: How can I show the total quantity of all products ordered?
A: This is not a default feature. It can be achieved by creating a custom template with PHP to calculate and display the sum of all item quantities.

Q: My invoice shows the weight twice for variable products. How do I fix it?
A: This is usually caused by a third-party plugin adding weight data as item meta. You can use a code snippet to hide the duplicate entry once you identify its source in the HTML output.

Q: Can I generate an invoice for a free order?
A: Yes. In the plugin's settings under WooCommerce > PDF Invoices > Documents > Invoice, simply uncheck the "Disable for free orders" option.

Q: Why are my discounts not showing per item?
A: The free template shows discounts in the order totals section, not per item line. To display itemized discounts, you would need to use the customizer in the Premium Templates extension.

Conclusion

Displaying custom data on your PDF invoices is possible through either custom code or the Premium Templates extension. The best method for you depends on your technical comfort level and specific needs. Always remember to first identify how and where your desired data is stored before attempting to display it.

Related Support Threads Support