Hello @martintenboske,
You can add custom fields to your invoices and packing slips 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 delivery_date
, then you could add this field to your packing slips using the following code snippet:
add_action( 'wpo_wcpdf_after_billing_address', 'wpo_wcpdf_delivery_date', 10, 2 );
function wpo_wcpdf_delivery_date ($template_type, $order) {
? ? $document = wcpdf_get_document( $template_type, $order );
? ? if ($template_type == 'packing-slip') {
? ? ? ? ?>
? ? ? ? <tr class="delivery-date">
? ? ? ? ? ? <th>Delivery Date:</th>
? ? ? ? ? ? <td><?php $document->custom_field('delivery_date'); ?></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 your specific case, 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
Let me know if you have more questions ??