# Today's Sales Dashboard Widget

> Adds a dashboard widget showing today's number of orders, revenue and average order value, so you can check the day at a glance.

- Type: PHP
- Runs: Admin only
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, dashboard, reports, sales
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-todays-sales-widget/

## Code

```php
add_action( 'wp_dashboard_setup', function () {
    if ( ! current_user_can( 'view_woocommerce_reports' ) ) {
        return;
    }

    wp_add_dashboard_widget( 'wpide_todays_sales', 'Today\'s sales', function () {
        $start  = new DateTime( 'today', wp_timezone() );
        $orders = wc_get_orders( array(
            'status'       => array( 'wc-processing', 'wc-completed', 'wc-on-hold' ),
            'date_created' => '>=' . $start->getTimestamp(),
            'limit'        => -1,
            'type'         => 'shop_order',
        ) );

        $count   = count( $orders );
        $revenue = 0;

        foreach ( $orders as $order ) {
            $revenue += (float) $order->get_total() - (float) $order->get_total_refunded();
        }

        $average = $count ? $revenue / $count : 0;

        echo '<table class="widefat striped"><tbody>';
        printf( '<tr><td>Orders</td><td><strong>%d</strong></td></tr>', (int) $count );
        printf( '<tr><td>Revenue</td><td><strong>%s</strong></td></tr>', wp_kses_post( wc_price( $revenue ) ) );
        printf( '<tr><td>Average order</td><td><strong>%s</strong></td></tr>', wp_kses_post( wc_price( $average ) ) );
        echo '</tbody></table>';
        $hpos = class_exists( '\\Automattic\\WooCommerce\\Utilities\\OrderUtil' ) && \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled();
        printf( '<p><a href="%s">View orders</a></p>', esc_url( admin_url( $hpos ? 'admin.php?page=wc-orders' : 'edit.php?post_type=shop_order' ) ) );
    } );
} );
```

## Notes

Counts orders in processing, completed and on-hold status created since midnight in the site timezone.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Today's Sales Dashboard Widget" 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/
