Support » Plugin: WooCommerce PDF Invoices & Packing Slips » non-legacy way of displaying custom billing field

  • Resolved Jose Luis Cruz



    I need to display an additional custom field in the billing section of the invoice PDF. So far the only code that works is using the deprecated $wpo_wcpdf global, which works in legacy mode:

    add_filter( 'wpo_wcpdf_billing_address', 'incluir_nif_en_factura' );
    function incluir_nif_en_factura( $address ) {
            global $wpo_wcpdf;
            echo $address . '<p>';
            $wpo_wcpdf->custom_field( 'billing_nif', 'NIF/DNI/CIF: ' );
            echo '</p>';

    I tried to do it in a new way as the documentation recommends: But there are no hooks for billing in there.

    in templates/Simple/invoice.php file, line 33. I see the undocumented action wpo_wcpdf_after_billing_address. But so far I’ve been unable to make it display anything. While using other hooks like wpo_wcpdf_after_order_data does work.

    Am I missing something? What would be the new way of displaying additional fields on the billing section?

    thank you very much for your great plugin (I already bought the Premium Templates add-on BTW)

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support kluver


    Hi @joseluiscruz,

    If you already bought our Premium Templates extension you can add your custom field with a custom block in the Customizer. Please read: Using custom blocks

    You are also entitled to premium support with one of our paid extensions so in the future you can address your questions to:

    I hope this helps!

    Thread Starter Jose Luis Cruz


    Thank you @kluver,

    I’ve just tried using custom blocks. And it works, except that it’s not possible to show the block close to the billing data, like I can using the legacy system.

    I’m using the modern template. The closer options given are to show it before and after the order data.

    Do you plan to add additional hooks for displaying custom blocks after/before the billing data?

    Plugin Author Ewout


    Hello Jose,
    These are actually included in the latest update (Premium Templates 2.5.7), so please check that you are using the latest version. WordPress does not allow us to use these forums for supporting the premium extensions, so if you have more questions about this, please contact us via email – thanks!

    Answering the original question, if you prefer doing this with the action hook (although I recommend the above method since it doesn’t require any code to maintain), this should work in the free version too:

    add_filter( 'wpo_wcpdf_billing_address', 'incluir_nif_en_factura', 99, 2 );
    function incluir_nif_en_factura( $address, $document = null ) {
        if (!empty($document->order) && $nif = $document->get_custom_field('ebay_order_id') ) {
            $address = $address . "<p>NIF/DNI/CIF: {$nif}</p>";
        return $address;
    Thread Starter Jose Luis Cruz


    Thank you!

    The custom code works well, and I understand how the new hooks works now, which makes me very happy.

    Since the website didn’t receive a notice for the available update of the templates plugin, I had to download it manually. But it now works using custom blocks too.

    thank you very much for your quick fantastic support

    Plugin Author Ewout


    Glad to hear that Jose! To receive updates, you need to activate the license:

    Again, if you have any issues with the paid extensions, please email us, does not allow us to use these forums for paid support!


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘non-legacy way of displaying custom billing field’ is closed to new replies.