• I installed the How did you hear about us plugin which created a new field? How can we get this field to show up on the pdf invoice?

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

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

    (@yordansoares)

    This can be done without any code using a custom block within the customizer, included in the Premium Templates extension, or adding some PHP code, using our PDF template action hooks.

    If you choose the first option, you just need to add a custom block with these settings:

    A custom block used to display the VAT number

    In the case that you prefer to try with code, add  this code snippet to your site:

    
    /**
     * WooCommerce PDF Invoices & Packing Slips:
     * Show the VAT number on the invoice
     */
    add_action( 'wpo_wcpdf_after_billing_address', function( $document_type, $order ){
        if( $document_type == 'invoice' ) {
            if ( $vat_number = $order->get_meta( 'vat_number' ) ){
                echo '<div>VAT: ' . $vat_number . '</div>';
            }
        }
    }, 10, 2 );
    

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters.

    In the examples above, it shows how to add the VAT Number, that is a custom field with the meta key 'vat_number'. You need to replace the label and the field meta key with your actual custom field meta key.

    Let me know if you manage to display your custom field in your invoices!

Viewing 1 replies (of 1 total)

The topic ‘Add New Field to PDF’ is closed to new replies.