Hi @nchfrc,
If this is the only customization you want to add to the document (to display a custom field), please try switching to our Simple template again a activating this code snippet in your site:
/**
* PDF Invoices & Packing Slips for WooCommerce:
* Incluye el NIF en los documentos PDF (dentro de los datos de facturación)
*/
add_filter( 'wpo_wcpdf_billing_address', function( $address, $document ) {
if ( ! empty( $document ) && is_callable( array( $document, 'get_custom_field' ) ) && ( $nif = $document->get_custom_field( '_billing_wooccm11' ) ) ) {
$address .= sprintf( '<p>DNI/NIE/CIF:: %s</p>', $nif );
}
return $address;
}, 10, 2 );If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters
* FYI: Although you can certainly achieve this creating a custom PDF template as well, but please note that we do not provide assistance for it for free. Even if you have a license for either Professional extension or Premium Templates, we only offer help for this as a custom job for an extra fee, since this is an advanced customization which involves more time and work (and I believe it is not necessary for small customizations as the one you need to apply).
Thread Starter
nchfrc
(@nchfrc)
Thanks very much for the quick reply Yordan. I’ve never done this so pardon my question – can I place this in template-functions.php (not sure if this is the same as the ‘functions.php’ referenced in the link) or should I download the Code Snippets plugin?
Good question, @nchfrc:
If you have a child theme, you can add code snippets in its functions.php file (it is inside the child theme folder): don’t add code snippets to the functions.php file from your parent theme, because you may lose your customizations after updating your parent theme! The another way to add code snippets, that is safer in my humble opinion, is to use the Code Snippets plugin (or a similar plugin that allows you to add custom code from your site’s dashboard): This plugin stores the code snippets in your database, so you don’t have to worry about losing your customizations after updating your plugins or theme 😉
Thread Starter
nchfrc
(@nchfrc)
Thanks again for the quick help Yordan, I used Code Snippets and I can now see the custom field on the invoices 🙂
Thanks for confirming that it worked, @nchfrc!
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!
