• Resolved lomacs

    (@lomacs)


    Hello, after the latest update our custom field to add NIF/VAT to invoice does not work anymore.

    I had to revert to older version.

    This is the code that I’m currently using:

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

    Thanks.

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

    (@yordansoares)

    Hi @lomacs,

    Please note that this happened because you are using deprecated code that we started removing on the latest version. Actually, these legacy code is very old, that we kept them for long time in order to provide support to old WooCommerce versions. However, since WooCommerce started bumping the minimal requirements, we chose to follow the same approach.

    That said, please replace that code snippet with this one to fix the issue:

    /**
     * PDF Invoices & Packing Slips for WooCommerce:
     * Mostrar 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 lomacs

    (@lomacs)

    It works. Thanks you so much.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I’m glad to hear that, @lomacs!

    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 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom field does not work with latest update’ is closed to new replies.