• marcoloprete

    (@marcoloprete)


    Hi,
    on my website I have custom fields in the checkout made with Checkout Field Editor for WooCommerce (Pro). You can check them here: https://imgur.com/a/lLV00Rh. Is it possibile to add them to the PDF invoice?
    Thanks!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • moksha shah

    (@mokshasharmila13)

    Hi @marcoloprete

    For adding custom fields on your invoice, please add the below code in your active theme’s functions.php file or use a plugin like Code Snippets:

    function example_custom_order_fields( $fields, $order ) {
    	$new_fields = array();
    		
    	if( get_post_meta( $order->get_id(), 'your_meta_field_name', true ) ) {
    		$new_fields['your_meta_field_name'] = array( 
    			'label' => 'VAT',
    			'value' => get_post_meta( $order->get_id(), 'your_meta_field_name', true )
    		);
    	}
    	
    	if( get_post_meta( $order->get_id(), 'your_meta_field_name', true ) ) {
    		$new_fields['your_meta_field_name'] = array( 
    			'label' => 'Customer Number',
    			'value' => get_post_meta( $order->get_id(), 'your_meta_field_name', true )
    		);
    	}
    	
    	return array_merge( $fields, $new_fields );
    }
    add_filter( 'wcdn_order_info_fields', 'example_custom_order_fields', 10, 2 );

    Please let us know if you need any further help.

    Regards,
    Moksha.

Viewing 1 replies (of 1 total)
  • The topic ‘Add custom fields to the invoice made with Checkout Field Editor for WooCommerce’ is closed to new replies.