• Resolved KatrineDS

    (@katrineds)


    Hi,
    I get an error when I try do open invoices. The packing slips works fine.
    Det error I get:

    Fatal error: Call to a member function get_id() on boolean
    #0 /customers/a/f/9/stuhrling.dk/httpd.www/wp-includes/class-wp-hook.php(288): Vc_Aino_Order->add_pdf_information('22474405', Object(WPO\WC\PDF_Invoices\Documents\Invoice))
    #1 /customers/a/f/9/stuhrling.dk/httpd.www/wp-includes/plugin.php(206): WP_Hook->apply_filters('22474405', Array)
    #2 /customers/a/f/9/stuhrling.dk/httpd.www/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document-methods.php(155): apply_filters('wpo_wcpdf_billi...', '22474405', Object(WPO\WC\PDF_Invoices\Documents\Invoice))
    #3 /customers/a/f/9/stuhrling.dk/httpd.www/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document-methods.php(158): WPO\WC\PDF_Invoices\Documents\Order_Document_Methods->get_billing_phone()
    #4 /customers/a/f/9/stuhrling.dk/httpd.www/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/templates/Simple/invoice.php(39): WPO\WC\PDF_Invoices\Documents\Order_Document_Methods->billing_phone()
    #5 /customers/a/f/9/stuhrling.dk/httpd.www/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(738): include('/customers/a/f/...')
    #6 /customers/a/f/9/stuhrling.dk/httpd.www/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(642): WPO\WC\PDF_Invoices\Documents\Order_Document->render_template('/customers/a/f/...', Array)
    #7 /customers/a/f/9/stuhrling.dk/httpd.www/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(624): WPO\WC\PDF_Invoices\Documents\Order_Document->get_html()
    #8 /customers/a/f/9/stuhrling.dk/httpd.www/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(660): WPO\WC\PDF_Invoices\Documents\Order_Document->get_pdf()
    #9 /customers/a/f/9/stuhrling.dk/httpd.www/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/class-wcpdf-main.php(337): WPO\WC\PDF_Invoices\Documents\Order_Document->output_pdf('inline')
    #10 /customers/a/f/9/stuhrling.dk/httpd.www/wp-includes/class-wp-hook.php(288): WPO\WC\PDF_Invoices\Main->generate_pdf_ajax('')
    #11 /customers/a/f/9/stuhrling.dk/httpd.www/wp-includes/class-wp-hook.php(312): WP_Hook->apply_filters('', Array)
    #12 /customers/a/f/9/stuhrling.dk/httpd.www/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
    #13 /customers/a/f/9/stuhrling.dk/httpd.www/wp-admin/admin-ajax.php(175): do_action('wp_ajax_generat...')
    #14 {main}

    What could be the error?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    This appears to be caused by a third party plugin with a class Wc_Aino_Order (this error was reported by someone else here but unfortunately without follow-up)

    You could try turning off plugins that you think may be related (perhaps with something like “Aino” in their name) or temporarily switch to a different theme.

    Let us know what you find!

    Plugin Contributor Ewout

    (@pomegranate)

    After receiving another report of this error I digged a little further and found the offending plugin: PostNord Delivery Checkout

    The error was already reported in that plugin support forum too, but unfortunately the developers (@vconnect / @vconnectmodules) have not responded yet.

    The issue is caused by legacy code in their plugin, written for PDF Invoices 1.X and not compatible with PDF Invoices 2.X (from 2017):

    
    add_filter('wpo_wcpdf_billing_phone', array($this, 'add_pdf_information'), 10, 3);
    function add_pdf_information($address) {
        global $wpo_wcpdf;
    
        $order_meta = get_post_meta($wpo_wcpdf->export->order->get_id());
    
        if ($order_meta['_vc_aio_options']) {
    
            foreach (unserialize($order_meta['_vc_aio_options'][0]) as $key => $vc_aio_option) {
                if(empty($vc_aio_option['hidden'])) {
                    $address .= $vc_aio_option['label'] . ': ' . $vc_aio_option['value'] . '<br />';
                }
            }
        }
    
        return $address;
    }
    

    To make this compatible with version 2.0+ it needs to be altered, first the filter arguments (2 instead of 3):

    
    add_filter('wpo_wcpdf_billing_phone', array($this, 'add_pdf_information'), 10, 2);
    

    and then the function itself:

    
    function add_pdf_information($phone_number, $document = null ) {
        if ( !empty($document->order) && $vc_aio_options = $document->order->get_meta('_vc_aio_options') ) {
            $vc_aio_options = maybe_unserialize( $vc_aio_options );
            if (empty($vc_aio_options) || !is_array($vc_aio_options)) {
                return $phone_number
            }
    
            foreach ($vc_aio_options as $key => $vc_aio_option) {
                if(empty($vc_aio_option['hidden'])) {
                    $phone_number .= $vc_aio_option['label'] . ': ' . $vc_aio_option['value'] . '<br />';
                }
            }
        }
    
        return $phone_number;
    }
    

    A few notes:

    • The code hooks into the wpo_wcpdf_billing_phone filter, which means that it is only added to the PDF when the “Show phone number” option is activated in the settings. It may be more appropriate to hook into the wpo_wcpdf_after_billing_address action (source).
    • I haven’t tested the above code but this should be enough for the developers to implement a solution
    • Two possible temporarily solutions (that don’t require any change in code): 1) Disable the “phone” option in the invoice settings and enable the “always use most current settings” option or 2) Enable “Legacy mode” on the Status tab of the plugin settings
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Invoice throws error’ is closed to new replies.