• Resolved brookie400

    (@brookie400)


    Im trying to add order status to the printed PDF but I cant figure it out. Ive tried many things but one of the two below I really thought would work. Can somebody help me please?

    function bks_add_extra_field( $fields, $order ) {
        $new_fields = array();
            
        //if( $order->get_status() ) {
          //  $new_fields['status'] = array( 
            //    'label' => 'Order Status',
              //  'value' => $order->get_status(),
           // );
       // }
    	
    	if( get_post_meta( $order->get_id(), 'status', true ) ) {
            $new_fields['status'] = array( 
                'label' => 'Order Status',
                'value' => get_post_meta( $order->get_id(), 'status', true )
            );
        }
    
        return array_merge( $fields, $new_fields );
    }
    add_filter( 'wcdn_order_info_fields', 'bks_add_extra_field', 10, 2 );
    • This topic was modified 3 years, 1 month ago by brookie400.
    • This topic was modified 3 years, 1 month ago by brookie400.
Viewing 1 replies (of 1 total)
  • moksha shah

    (@mokshasharmila13)

    Hello @brookie400,

    Your first code snippet is working fine for me. Here is the screenshot: https://prnt.sc/fCJ2bes___4k

    This is the exact code snippet that I added in my functions.php file and it displayed the order status on the printed invoice.

    function bks_add_extra_field( $fields, $order ) {
        $new_fields = array();
            
        if( $order->get_status() ) {
           $new_fields['status'] = array( 
                'label' => 'Order Status',
                'value' => $order->get_status(),
            );
       }
    return array_merge( $fields, $new_fields );
    }
    add_filter( 'wcdn_order_info_fields', 'bks_add_extra_field', 10, 2 );
Viewing 1 replies (of 1 total)
  • The topic ‘WP 5.9.1 Add order status to PDF’ is closed to new replies.