# fluent-cart/1.3.26/app/Hooks/Scheduler/AutoSchedules/DailyScheduler.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.3.26. 51 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.3.26/code/app/Hooks/Scheduler/AutoSchedules/DailyScheduler.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.3.26/raw/app/Hooks/Scheduler/AutoSchedules/DailyScheduler.php
- Modified: 2026-04-28T13:36:36+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.3.26/code/app/Hooks/Scheduler/AutoSchedules/DailyScheduler.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Hooks\Scheduler\AutoSchedules;


use FluentCart\App\Models\Cart;

class DailyScheduler
{

    private $startTimeStamp = null;

    public function register(): void
    {
        add_action('fluent_cart/scheduler/daily_tasks', [$this, 'handle']);
    }

    public function handle()
    {
        $this->startTimeStamp = time();
        $this->deleteOldCarts();
    }


    private function deleteOldCarts()
    {
        
        if ((time() - $this->startTimeStamp) > 40) {
            return; // Prevent long execution
        }

        $days = apply_filters('fluent_cart/cleanup/old_carts_days', 30);

        $carts = Cart::query()
            ->where('updated_at', '<=', date('Y-m-d H:i:s', strtotime('-' . $days . ' days')))
            ->limit(1000)
            ->get();

        if ($carts->isEmpty()) {
            return;
        }

        foreach ($carts as $cart) {
            $cart->delete();
        }

        // Recursively call to delete more carts
        $this->deleteOldCarts();
    }
}

```
