# Recent Orders on the My Account Dashboard

> Lists the customer's three latest orders with status and total on the My Account dashboard, so they see what matters without clicking through.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, my-account, orders, customers
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-account-recent-orders/

## Code

```php
$wpide_recent_count = 3; // Orders to show.

add_action( 'woocommerce_account_dashboard', function () use ( $wpide_recent_count ) {
    $orders = wc_get_orders( array(
        'customer_id' => get_current_user_id(),
        'limit'       => $wpide_recent_count,
        'orderby'     => 'date',
        'order'       => 'DESC',
        'status'      => array_keys( wc_get_order_statuses() ),
    ) );

    if ( ! $orders ) {
        return;
    }

    echo '<h3>' . esc_html( 'Your recent orders' ) . '</h3><table class="woocommerce-orders-table shop_table shop_table_responsive"><thead><tr><th>' . esc_html( 'Order' ) . '</th><th>' . esc_html( 'Date' ) . '</th><th>' . esc_html( 'Status' ) . '</th><th>' . esc_html( 'Total' ) . '</th></tr></thead><tbody>';

    foreach ( $orders as $order ) {
        printf(
            '<tr><td data-title="%1$s"><a href="%2$s">#%3$s</a></td><td data-title="%4$s">%5$s</td><td data-title="%6$s">%7$s</td><td data-title="%8$s">%9$s</td></tr>',
            esc_attr( 'Order' ),
            esc_url( $order->get_view_order_url() ),
            esc_html( $order->get_order_number() ),
            esc_attr( 'Date' ),
            esc_html( wc_format_datetime( $order->get_date_created() ) ),
            esc_attr( 'Status' ),
            esc_html( wc_get_order_status_name( $order->get_status() ) ),
            esc_attr( 'Total' ),
            wp_kses_post( $order->get_formatted_order_total() )
        );
    }

    echo '</tbody></table>';
} );
```

## Notes

Change $wpide_recent_count to show more or fewer orders.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Recent Orders on the My Account Dashboard" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
