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
-
Adding One Line Below Weighthttps://wordpress.org/support/topic/adding-one-line-below-weight/
-
Show Cost, Quantity and Totalhttps://wordpress.org/support/topic/show-cost-quantity-and-total/
-
Show shipping class and price on invoicehttps://wordpress.org/support/topic/show-shipping-class-and-price-on-invoice/
-
Multiple Weight Due to Variationshttps://wordpress.org/support/topic/multiple-weight-due-to-variations/
-
why is product cost not shown on PDF Invoice?https://wordpress.org/support/topic/why-is-product-cost-not-shown-on-pdf-invoice/
-
Add Unit price in default templatehttps://wordpress.org/support/topic/unit-price-no-longer-shown-on-default-template/
-
How to add Total Product Quantityhttps://wordpress.org/support/topic/how-to-add-total-product-quantity/
-
Show Unit Pricehttps://wordpress.org/support/topic/show-unit-price-2/
-
Total amount of products in PDF invoicehttps://wordpress.org/support/topic/total-amount-of-products-in-pdf-invoice/
-
Front page with invoice totals (bulk)https://wordpress.org/support/topic/front-page-with-invoice-totals-bulk/
-
How to display the gift card as a Way of payement on the invoicehttps://wordpress.org/support/topic/how-to-display-the-gift-card-as-a-way-of-payement-on-the-invoice/
-
Rate fieldhttps://wordpress.org/support/topic/rate-field/
-
Product Price doesn’t show its unit pricehttps://wordpress.org/support/topic/product-price-doesnt-show-its-single-price/
-
How to get total order price separetlyhttps://wordpress.org/support/topic/how-to-get-total-order-price-separetly/
-
Discounts on invoices?https://wordpress.org/support/topic/discounts-on-invoices-2/
-
Possible to add different total etc?https://wordpress.org/support/topic/possible-to-add-different-total-etc/
-
Add Amount Paid to invoicehttps://wordpress.org/support/topic/add-amount-paid-to-invoice/
-
Row count and total product counthttps://wordpress.org/support/topic/row-count-and-total-product-count/
-
order_item_qty in the loophttps://wordpress.org/support/topic/order_item_qty-in-the-loop/
-
PDF Invoice – layout questionhttps://wordpress.org/support/topic/pdf-invoice-layout-question/
-
How to get more details to be shown on Invoicehttps://wordpress.org/support/topic/how-to-get-more-details-to-be-shown-on-invoice/
-
Display net_totalhttps://wordpress.org/support/topic/display-net_total/
-
Unit product price/ single price.https://wordpress.org/support/topic/unit-product-price-single-price/
-
Invoice even for free productshttps://wordpress.org/support/topic/invoice-even-for-free-products/
-
How to show ‘Amount Pid’ and ‘balance’ on the invoicehttps://wordpress.org/support/topic/how-to-show-amount-pid-and-balance-on-the-invoice/