Support

Account

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;
    }