• Resolved sunrootsoftit

    (@sunrootsoftit)


    Hello,

    I have created an extra checkout field using this plugin (https://tinyurl.com/yu4jnx7h) but it does not add that extra field value to the pdf invoice.

    Send me suggestions on how I can attach that extra value to the pdf layout.

    Thank you.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    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:

    A screenshot that display an use example of the custom blocks

    Then, your invoices will display your custom field:

    A screenshot that display the example custom field on the invoice

    If you don’t know the name of your custom field, see Finding WooCommerce custom fields

Viewing 1 replies (of 1 total)
  • The topic ‘Add custom checkout field value to pdf invoice’ is closed to new replies.