• Resolved Brian

    (@briansedero)


    Hi there,

    Since I updated the plugin of our client to the newest version, both the buttons for making an invoice PDF and packing slip PDF throw the same error (Fatal error: Call to a member function get_header_logo_id() on null).

    Fatal error: Call to a member function get_header_logo_id() on null/home/sed029/domains/SITENAME/public_html/wp-content/themes/SITETHEME/woocommerce/pdf/SITENAME/packing-slip.php (6)
    #0 /home/sed029/domains/SITENAME/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(976): include()
    #1 /home/sed029/domains/SITENAME/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(879): WPO\WC\PDF_Invoices\Documents\Order_Document->render_template()
    #2 /home/sed029/domains/SITENAME/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(834): WPO\WC\PDF_Invoices\Documents\Order_Document->get_html()
    #3 /home/sed029/domains/SITENAME/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(901): WPO\WC\PDF_Invoices\Documents\Order_Document->get_pdf()
    #4 /home/sed029/domains/SITENAME/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/class-wcpdf-main.php(466): WPO\WC\PDF_Invoices\Documents\Order_Document->output_pdf()
    #5 /home/sed029/domains/SITENAME/public_html/wp-includes/class-wp-hook.php(310): WPO\WC\PDF_Invoices\Main->generate_pdf_ajax()
    #6 /home/sed029/domains/SITENAME/public_html/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters()
    #7 /home/sed029/domains/SITENAME/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
    #8 /home/sed029/domains/SITENAME/public_html/wp-admin/admin-ajax.php(188): do_action()
    #9 {main}

    After looking into it a little, we can see that the error comes from this particular piece of code in both custom template files packing-slip.php and invoice.php:

    <?php		
    if( $wpo_wcpdf->get_header_logo_id() ){
    	$wpo_wcpdf->header_logo();		
    } else {			
    	echo apply_filters( 'wpo_wcpdf_invoice_title', __( 'Invoice', 'wpo_wcpdf' ) );
    }
    ?>

    I already saw a few posts on this forum about a few errors/notices because of using deprecated code from old WooCommerce versions, so my question is this:

    Would you guys be willing to supply me the newer version of this piece of code? If you need the full template file(s) .php or more info, please let me know.

    Thanks for your time!

    • This topic was modified 1 year, 6 months ago by Brian.
    • This topic was modified 1 year, 6 months ago by Brian. Reason: Added full fatal error notice
    • This topic was modified 1 year, 6 months ago by Yui.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Brian

    (@briansedero)

    Sorry for posting, I already contacted them through email and got an immediate answer!

    Same Problem, Receive the following error when attempting to create a pdf invoice: Fatal error: Call to a member function get_header_logo_id() on null/users/nmpob/public_html/nmpob.org/wp-content/themes/panoramic-child-pob/woocommerce/pdf/POB Packing Slip/invoice.php (8)

    WordPress 6.3.1 running Panoramic theme.
    Server running PHP version: 8.1.17.
    PDF Invoices & Packing Slips for WooCommerce plugin Version 3.6.3

    Plugin Contributor Yordan Soares

    (@yordansoares)

    @briansedero I’m glad to hear that you managed to updated the code of your custom PDF template.

    @abqdanj please open a new topic here, so we can continue the conversation for your case there.

    Thread Starter Brian

    (@briansedero)

    For anyone wondering, this was the solution:

    This issue is happening because in the last release we deleted legacy code that we were maintaining for years. Currently, the global variable $wpo_wcpdf no longer exists, that is why the error is generated.

    However, you can follow these steps to fix this issue:

    1. Replace the whole code of the html-document-wrapper.php file with the current one you will find here.
    2. Open the invoice.php file, and do the following:
      1. Replace the first like with this one:
        <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
      2. Replace every concurrence of $wpo_wcpdf with $this
      3. Replace every concurrence of 'wpo_wcpdf' with 'woocommerce-pdf-invoices-packing-slips': This is the text domain which is needed in order for translations to work.
    3. If need it, repeat the steps of the 2nd point for the packing slip too.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Fatal error: Call to a member function get_header_logo_id() on null’ is closed to new replies.