Support

Account

Home Forums General Issues Display ACF fields in WooCommerce Invoice / Order Confirmation

Solving

Display ACF fields in WooCommerce Invoice / Order Confirmation

  • Hello,

    I have set-up WooCommerce but want to sell tickets for events as opposed to products.

    I can do this easy enough by adding ACF fields to be displayed on the archive page and the single event (product) pages to make it appear as a ticket. But I also want to display these fields on the ‘Order Confirmation’ page and the PDF invoice that is sent out to the purchaser.

    These would be custom fields such as ‘Event Address’, ‘Time of Event’, ‘Type of Ticket’… to name a few.

    Is this possible, and if so – can somebody please advise??

    Thanks in advance
    Elliott

  • 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;
    }
  • Last 2 show same thing. Have to edit last one to show only year, not month and day.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Display ACF fields in WooCommerce Invoice / Order Confirmation’ is closed to new replies.