Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Show Admin Added Notes in  My Account >View Orders Page for Completed Orders in WooCommerce?

By default, WooCommerce tends to display the admin entered order notes in My Account >view orders page of the Order Updates section. But we can also limit the display of order notes to completed order statuses so that customers receive necessary information only at the most relevant stage of the order process.

Solution: Show Admin Added Notes in  My Account >View Orders Page for Completed Orders in WooCommerce

The code checks if the order status is ‘completed’ and if the current page is the ‘view-order’ endpoint. If the conditions are met, the code retrieves the latest order note for the current order using the wc_get_order_notes() and display the admin order notes in the order details table.

add_filter( 'woocommerce_get_order_item_totals', 'ts_account_view_order_last_order_note', 10, 3 );
function ts_account_view_order_last_order_note( $total_rows, $order, $tax_display ){
    // For "completed" orders on my account view order pages
    if( $order->has_status('completed')  && is_wc_endpoint_url( 'view-order' ) ){

        // Get last order note
        $latest_notes = wc_get_order_notes( array(
            'order_id' => $order->get_id(),
            'limit'    => 1,
            'orderby'  => 'date_created_gmt',
        ) );

        $latest_note = current( $latest_notes );

        if ( isset( $latest_note->content ) ) {
            // Add a new row for tracking
            $total_rows['order_tracking'] = array(
                'label' => __('Admin Note:','woocommerce'),
                'value' => $latest_note->content
            );
        }
    }

    return $total_rows;
}

Output

Once an order transitions to the completed status and contains any admin order notes, these notes will be visible to the customer on the My Account > View Order page of WooCommerce.

Show Admin Added Notes in  My Account >View Orders Page

Alternatively, you can also send processing order email to admin email notifications that helps admin to track the processing stage of the order.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x