• Resolved lurim

    (@lurim)


    Hello,

    I’m experiencing a fatal error in the WooCommerce admin order screen when using PDF Invoices & Packing Slips for WooCommerce. Environment

    • WordPress: 6.9
    • WooCommerce: current (latest stable)
    • Plugin: PDF Invoices & Packing Slips for WooCommerce 5.6.0
    • PHP: 8.1
    • Hosting: All-Inkl

    Description

    The shop frontend works perfectly:

    • Orders are placed successfully
    • Payments (Mollie) are completed
    • Emails are sent
    • PDF invoices are generated correctly

    However, when opening an order in the WooCommerce backend, the metabox “PDF Document Data” shows a critical error and the admin page breaks partially. Error message

    Fatal error: Uncaught Error: Call to a member function get_prefix() on string
    in wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/Admin.php:990

    This seems to happen while loading the admin metabox.
    Even disabling the metabox via hooks does not help, which suggests the error occurs during file load. Notes

    • The issue also occurred with PHP 8.5 (worse), PHP 8.1 reduced it to backend-only
    • Downgrading PHP is not preferred for security reasons
    • Downgrading the plugin has not been tested yet
    • This looks like a compatibility issue with PHP 8.x in the admin code

    Question

    Is this a known bug in version 5.6.0?
    Is there a planned fix or recommended workaround (besides downgrading the plugin)?

    Thanks for your work on the plugin and any guidance you can provide.

    Best regards

    • This topic was modified 4 months, 1 week ago by lurim.
    • This topic was modified 4 months, 1 week ago by lurim.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @lurim,

    Could you try updating the plugin up to the latest release, which currently is 5.7.0?

    Let me know if it fixed the issue, or not!

    Thread Starter lurim

    (@lurim)

    Hi Yordan, I hope you got my email. Just to be sure – the error isn’t fixed .
    Do you have an idea when it’s solved – wordpress sends me daily an email with this content

    Fehler-Details

    ==============

    Ein Fehler vom Typ E_ERROR wurde in der Zeile 1018 der Datei /www/htdocs/w0204759/connywolf.com/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/Admin.php verursacht. Fehlermeldung: Uncaught Error: Call to a member function get_prefix() on string in /www/htdocs/w0204759/connywolf.com/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/Admin.php:1018

    Stack trace:

    #0 /www/htdocs/w0204759/connywolf.com/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/Admin.php(1152): WPO\IPS\Admin->get_current_values_for_document_data(Object(WPO\IPS\Documents\Invoice), Array)

    #1 /www/htdocs/w0204759/connywolf.com/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/Admin.php(992): WPO\IPS\Admin->output_number_date_edit_fields(Object(WPO\IPS\Documents\Invoice), Array)

    #2 /www/htdocs/w0204759/connywolf.com/wp-admin/includes/template.php(1453): WPO\IPS\Admin->data_input_box_content(Object(Automattic\WooCommerce\Admin\Overrides\Order), Array)

    #3 /www/htdocs/w0204759/connywolf.com/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/Edit.php(506): do_meta_boxes(Object(WP_Screen), 'normal', Object(Automattic\WooCommerce\Admin\Overrides\Order))

    #4 /www/htdocs/w0204759/connywolf.com/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/Edit.php(410): Automattic\WooCommerce\Internal\Admin\Orders\Edit->render_meta_boxes()

    #5 /www/htdocs/w0204759/connywolf.com/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/PageController.php(295): Automattic\WooCommerce\Internal\Admin\Orders\Edit->display()

    #6 /www/htdocs/w0204759/connywolf.com/wp-includes/class-wp-hook.php(341): Automattic\WooCommerce\Internal\Admin\Orders\PageController->output('')

    #7 /www/htdocs/w0204759/connywolf.com/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters('', Array)

    #8 /www/htdocs/w0204759/connywolf.com/wp-includes/plugin.php(522): WP_Hook->do_action(Array)

    #9 /www/htdocs/w0204759/connywolf.com/wp-admin/admin.php(264): do_action('woocommerce_pag...')

    #10 {main}

      thrown
    Plugin Contributor Mohamad

    (@mohamadntr)

    Hi @lurim,

    Could you please contact us through [email protected] so we can further investigate this issue?

    Thread Starter lurim

    (@lurim)

    Hi Mohamad,
    I sent you an email just now

    best regards

    Lutz

    Thread Starter lurim

    (@lurim)

    @mohamad,
    thank you for your advice. I made the change in the code of snippets and it works now fine.
    Maybe somebody is interested

    /**

    • PDF Invoices & Packing Slips: Erweiterte Platzhalter für Rechnungsnummern
    • [yy] = 2-stelliges Jahr (z. B. 25 für 2025)
    • [invoice_year] = 4-stellig (z. B. 2025)
    • [number] = fortlaufende Rechnungsnummer mit führenden Nullen
    • Fehlerfrei, auch wenn $document mal kein Objekt ist
      / /add_filter( ‘wpo_wcpdf_invoice_number’, function( $number, $type, $document ) { */
      add_filter( ‘wpo_wcpdf_format_document_number’, function( $number, $type, $document ) { // 1. Standard-Jahr 4-stellig
      $invoice_year = date_i18n(‘Y’); // Default
      $yy = date_i18n(‘y’); // 2-stelliges Jahr Default // 2. Prüfen, ob $document ein Objekt ist
      if ( is_object( $document ) && method_exists( $document, ‘get_date’ ) ) {
      $date = $document->get_date();
      if ( $date ) {
      $invoice_year = date_i18n( ‘Y’, strtotime( $date ) );
      $yy = date_i18n( ‘y’, strtotime( $date ) );
      }
      } // 3. Platzhalter ersetzen
      $number = str_replace( ‘[invoice_year]’, $invoice_year, $number );
      $number = str_replace( ‘[yy]’, $yy, $number ); // [number] bleibt unverändert (wird vom Plugin gesetzt)
      return $number;

    }, 10, 3 );

    best regards
    Lutz

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.