• Resolved AngeloLazzari

    (@angelolazzari)


    Hi, since 2017 we use your plugin and we used this code to include in the invoice a custom field we have in the order ( using the plugin Checkout Field Editor (Checkout Manager) for WooCommerce – WordPress plugin | www.ads-software.com) …. the code is the following:

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

    we update to the last version and the code give us an error on creating the invoice:

    Fatal error: Call to a member function custom_field() on null
    /var/www/html/wordpress/wp-content/themes/ascend_premium_child/functions.php (211)
    #0 /var/www/html/wordpress/wp-includes/class-wp-hook.php(326): incluir_nif_cif_en_factura()
    #1 /var/www/html/wordpress/wp-includes/plugin.php(205): WP_Hook->apply_filters()
    #2 /var/www/html/wordpress/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document-methods.php(93): apply_filters()
    #3 /var/www/html/wordpress/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document-methods.php(102): WPO\WC\PDF_Invoices\Documents\Order_Document_Methods->get_billing_address()
    #4 /var/www/html/wordpress/wp-content/themes/ascend_premium_child/woocommerce/pdf/Simple Premium No fecha pedido si envio /invoice.php(31): WPO\WC\PDF_Invoices\Documents\Order_Document_Methods->billing_address()
    #5 /var/www/html/wordpress/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(1138): include('/var/www/html/w...')
    #6 /var/www/html/wordpress/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(982): WPO\WC\PDF_Invoices\Documents\Order_Document->render_template()
    #7 /var/www/html/wordpress/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(937): WPO\WC\PDF_Invoices\Documents\Order_Document->get_html()
    #8 /var/www/html/wordpress/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(1004): WPO\WC\PDF_Invoices\Documents\Order_Document->get_pdf()
    #9 /var/www/html/wordpress/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/class-wcpdf-main.php(580): WPO\WC\PDF_Invoices\Documents\Order_Document->output_pdf()
    #10 /var/www/html/wordpress/wp-includes/class-wp-hook.php(324): WPO\WC\PDF_Invoices\Main->generate_document_ajax()
    #11 /var/www/html/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #12 /var/www/html/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action()
    #13 /var/www/html/wordpress/wp-admin/admin-ajax.php(188): do_action()
    #14 {main}

    how can we fix it? thank you very much

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

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

    (@yordansoares)

    Hi @angelolazzari,

    This issue is happening because that is a very outdated code. Please note that in v3.6.3 we have deleted legacy code that we were maintaining for years. Therefore, since the global variable?$wpo_wcpdf?no longer exists, this is returning errors in those methods called through it.

    That said, I have updated your code to make it work again:

    /**
     * PDF Invoices & Packing Slips for WooCommerce:
     * Incluir NIF en los documentos PDF
     */
    add_filter( 'wpo_wcpdf_billing_address', function( $address, $document ) {
    	if ( ( $order = $document->order ) && ( $nif = $order->get_meta( 'billing_nif_cif' ) ) ) {
    		$address .= sprintf( '<p>NIF/CIF: %s</p>', $nif ); 
    	}
    	return $address;
    }, 10, 2 );
    Thread Starter AngeloLazzari

    (@angelolazzari)

    thank you very much @yordansoares!!!! It worked perfectly!!!

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for confirming that it worked, @angelolazzari,

    Let us know if you need anything else ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Error after upgrade to 3.7.7 version’ is closed to new replies.