Hello @sunrootsoftit,
You can add custom fields to your invoices using the template action hooks. See several examples about adding new fields to your invoices here.
Let’s say your custom field is stored with the order meta key custom_field_name
, then you could add this field to your invoices using the following code snippet:
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_my_custom_field', 10, 2 );
function wpo_wcpdf_my_custom_field ($template_type, $order) {
? ??if ($template_type == 'invoice') {
? ? ? ???>
? ? ? ??<tr class="custom-field">
? ? ? ??<th>Custom Field:</th>
? ? ? ??<td><?php echo $order->get_meta('custom_field_name'); ?></td>
? ? ? ??</tr>
? ? ? ??<?php
? ??}
}
If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters
You can also add any field, without no code, using Premium Templates. This extension includes a customizer that allows you to tailor your PDF documents using product columns, total rows, and custom blocks. In addition, Premium Templates provides two additional templates: Business and Modern.
For instance, you only need to add a custom, block this way:
Then, your invoices will display your custom field:
If you don’t know the name of your custom field, see Finding WooCommerce custom fields