• Resolved lauratriv

    (@lauratriv)


    After the last update( PDF Invoices & Packing Slips for WooCommerce), a fatal error occurs when generating the invoice:

    Fatal error: Call to a member function custom_field() on null

    /home/algodonp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(581) : eval()’d code (62)

    Can you help me with this? Thanks in advance.

    Laura

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Darren Peyou

    (@dpeyou)

    Hello @lauratriv,

    The error message is referencing a code snippet entered via the code snippets plugin. Could you deactivate them one-by-one until you find the guilty snippet? once you find the guilty snippet, could you post that snippet’s code here?

    Are you by any chance using a custom PDF template?

    Thread Starter lauratriv

    (@lauratriv)

    Hi Darren, thanks for your quick reply.

    I’m not using a custom PDF template, here is the code that I think gives problems:

    56. add_filter( ‘wpo_wcpdf_billing_address’, ‘incluir_nif_en_factura’ );

    57.

    58. function incluir_nif_en_factura( $address ){
    59. global $wpo_wcpdf;

    60.

    61. echo $address . ‘

    62. ‘; $wpo_wcpdf->custom_field( ‘NIF’, ‘NIF: ‘ ); echo ”;

    63.
    64. }

    I have been using the plugin for a long time, including this code, this is the first time an update has given me problems.

    Thanks in advance.

    Laura

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @lauratriv,

    This issue is occurring because we recently removed legacy code that was being maintained for years. As a result, the global variable $wpo_wcpdf no longer exists, causing the error.

    That said, please replace the code snippet you mentioned above with this updated version:

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

    (@lauratriv)

    Hi Yordan,

    The problem has been fixed, now the code works perfectly.
    Thank you very much for the support.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for confirming that it is working now, @lauratriv! 🎉

    If you don’t mind and have the time, do you think you could leave us a review?

    Thanks in advance and all the best with your store!

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

The topic ‘Fatal error after last update’ is closed to new replies.