# fluent-cart/1.6.2/app/Services/Widgets/DashboardWidget.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.6.2. 81 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.6.2/code/app/Services/Widgets/DashboardWidget.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.6.2/raw/app/Services/Widgets/DashboardWidget.php
- Modified: 2025-10-14T16:36:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/1.6.2/code/app/Services/Widgets/DashboardWidget.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Services\Widgets;

use FluentCart\App\App;
use FluentCart\App\Helpers\Status;
use FluentCart\App\Models\Coupon;
use FluentCart\App\Models\Order;
use FluentCart\App\Models\Product;
use FluentCart\App\Services\DateTime\DateTime;
use FluentCart\App\Services\URL;


class DashboardWidget extends BaseWidget
{

    public function widgetName(): string
    {
        return 'dashboard_stats';
    }

    public function widgetData(): array
    {
        $startDate = (new DateTime())->subMonth()->startOfDay();
        $endDate = (new DateTime())->endOfDay();

        $counts = Product::query()->selectRaw("
            COUNT(*) as total_products
        ")
        ->whereNotIn('post_status', ['trash', 'auto-draft'])
        ->first();

        $sales = App::db()->table('fct_orders as o')->selectRaw("
            COUNT(o.id) AS orders,

            SUM(
                o.total_paid
                - o.total_refund
                - o.tax_total
                - o.shipping_tax
            ) / 100 AS net_revenue,

            SUM(o.total_refund) / 100 AS total_refunds
        ")
        ->whereBetween('o.created_at', [$startDate, $endDate])
        ->whereNotIn('o.status', [Status::ORDER_ON_HOLD, Status::ORDER_FAILED])
        ->first();
                
        return [
            [
                'title'         => __('Total Products', 'fluent-cart'),
                'current_count' => $counts->total_products,
                'icon'          => 'Frame',
                'url'           => URL::getDashboardUrl('products', [
                    'active_view' => 'all',
                ]),
            ],
            [
                'title'         => __('Orders', 'fluent-cart'),
                'current_count' => $sales->orders,
                'icon'          => 'AllOrdersIcon',
                'url'           => URL::getDashboardUrl('orders'),
            ],
            [
                'title'         => __('Revenue', 'fluent-cart'),
                'current_count' => $sales->net_revenue,
                'icon'          => 'Currency',
                'url'           => URL::getDashboardUrl('reports/revenue'),
                'has_currency'  => true,
            ],
            [
                'title'         => __('Refund', 'fluent-cart'),
                'current_count' => $sales->total_refunds,
                'icon'          => 'Failed',
                'url'           => URL::getDashboardUrl('reports/refunds'),
                'has_currency'  => true,
            ],
        ];
    }
}

```
