Home › Forums › General Issues › Display ACF fields in WooCommerce Invoice / Order Confirmation › Reply To: Display ACF fields in WooCommerce Invoice / Order Confirmation
Hi,
something like this can help you to put it on PDF invoice:
(those 3 are 3 ACF fields shown on shop_order)
/**
* Adding a custom field to the invoice
*
* Uses template tag [[CUSTOMFIELD]]
*
* custom field name : childname
*
* 1 - Edit template.php and add the tag in the desired place
* 2 - add code to the theme functions.php file
*/
add_filter ( 'pdf_content_additional_content' , 'pdf_additional_content_terms',10 ,2 );
function pdf_additional_content_terms( $content, $order_id ) {
global $woocommerce;
if ( isset( $order_id ) ) :
$content = str_replace( '[[RECHUNGSNUMMER]]', get_post_meta( $order_id, 'rechnungsnummer', TRUE ) , $content );
endif;
return $content;
}
add_filter ( 'pdf_content_additional_content' , 'pdf_additional_content_terms_2',10 ,2 );
function pdf_additional_content_terms_2( $content, $order_id ) {
global $woocommerce;
if ( isset( $order_id ) ) :
$content = str_replace( '[[RECHNUNGSDATUM]]', get_post_meta( $order_id, 'rechnungsdatum', TRUE ) , $content );
endif;
return $content;
}
add_filter ( 'pdf_content_additional_content' , 'pdf_additional_content_terms_3',10 ,2 );
function pdf_additional_content_terms_3( $content, $order_id ) {
global $woocommerce;
if ( isset( $order_id ) ) :
$content = str_replace( '[[RECHNUNGSDATUMYEAR]]', get_post_meta( $order_id, 'jahre', TRUE ) , $content );
endif;
return $content;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.