• Resolved caspervain

    (@caspervain)


    I am looking to display the last 3 Order Notes, currently only viewable via Admin in WooCommerce, on the customer side in their Order History.

    [Order notes][1]

    The goal is for them to view the tracking number added in after the order is set as complete.

    The code I currently have included in the child theme function.php file only shows the last order note on the customer order details.

    add_filter( 'woocommerce_get_order_item_totals', 'account_view_order_last_order_note', 10, 3 );
        function 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' => __('Tracking:','woocommerce'),
                        'value' => $latest_note->content
                    );
                }
            }
    
            return $total_rows;
        }
    

    This is the output —>
    [Customer Order Details][2]

    How can I show the last 3 Order Notes on the customer order history? No plugins seem to exist for Order Notes to be shown on the customer side.

    [1]: https://i.stack.imgur.com/hyWrO.png
    [2]: https://i.stack.imgur.com/5gDiN.png

    • This topic was modified 3 years, 8 months ago by caspervain.

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

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display last 3 WooCommerce admin order note in customers order history’ is closed to new replies.