Skip to content
Advertisement

add custom order status in Print Invoice & Delivery Notes for WooCommerce plugin

I want to add order status in print page using Invoice & Delivery Notes for WooCommerce plugin I tried this code and it didn’t work, what is the problem? my code :

function add_order_status( $fields, $order ) {
    $new_fields = array();

    if( get_post_meta( $order->get_status(), 'order-status', true ) ) {
        $new_fields['order-status'] = array( 
            'label' => 'Order Status',
            'value' => get_post_meta( $order->get_status(), 'order-status', true )
        );
    }
    return array_merge( $fields, $new_fields );
}
add_filter( 'wcdn_order_info_fields', 'add_order_status', 10, 2 );

Advertisement

Answer

You were very close to the correct code snippet. Please find the correct code below.

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

Screenshot: enter image description here


For anyone else who is looking to customize Invoice & Delivery Notes for WooCommerce plugin you can find the list of all the hooks here:

https://github.com/TycheSoftwares/Print-Invoice-Delivery-Notes-for-WooCommerce/wiki/Hooks-and-Filters-for-compatibility-and-minor-changes

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement