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?
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
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 );
Hi Yordan,
The problem has been fixed, now the code works perfectly.
Thank you very much for the support.
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!