| @@ -4,8 +4,10 @@ | ||
| 4 | 4 | |
| 5 | 5 | namespace Yatra\Hooks; |
| 6 | 6 | |
| 7 | 7 | use Yatra\Services\TripLifecycleCronService; |
| 8 | +use Yatra\Services\DepartureCronService; | |
| 9 | +use Yatra\Services\BookingCronService; | |
| 8 | 10 | |
| 9 | 11 | /** |
| 10 | 12 | * CronHooks |
| 11 | 13 | * Registers and runs scheduled tasks (trip lifecycle, etc.). |
| @@ -23,6 +25,36 @@ | ||
| 23 | 25 | // Daily handler |
| 24 | 26 | add_action(TripLifecycleCronService::CRON_HOOK, function () { |
| 25 | 27 | (new TripLifecycleCronService())->runDaily(); |
| 26 | 28 | }); |
| 29 | + | |
| 30 | + // Departure status cron: marks departures 'past' once their date passes. | |
| 31 | + // This was written but never wired here, so departures kept their old | |
| 32 | + // status forever — vanishing from the upcoming list (excluded by date) | |
| 33 | + // while never appearing under Past (which looked for status = 'past'). | |
| 34 | + // The Past query is now date-based too (see DepartureRepository), so | |
| 35 | + // display no longer depends on this cron; keeping the badge/status column | |
| 36 | + // current is what this maintains. | |
| 37 | + add_action('init', [DepartureCronService::class, 'registerCronHook']); | |
| 38 | + add_action('yatra_daily_departure_status_update', function () { | |
| 39 | + (new DepartureCronService())->dailyStatusUpdate(); | |
| 40 | + }); | |
| 41 | + | |
| 42 | + // Booking completion cron: marks confirmed bookings 'completed' once | |
| 43 | + // their tour date has passed, which is what fires the booking.completed | |
| 44 | + // email / Email Automation sequence. Self-guards against emailing | |
| 45 | + // historical bookings via an activation floor. | |
| 46 | + add_action('init', [BookingCronService::class, 'registerCompletionCron']); | |
| 47 | + add_action('yatra_booking_completion', [BookingCronService::class, 'completeFinishedBookings']); | |
| 48 | + | |
| 49 | + // Unpaid-booking expiry + pre-trip reminder. These two events were only | |
| 50 | + // ever scheduled (and only ever given a callback) inside | |
| 51 | + // BookingCronService::register(), which is not called anywhere — so the | |
| 52 | + // "Booking Expiry (hours)" setting expired nothing and the reminder | |
| 53 | + // email was only reachable through the admin's manual resend. Wiring | |
| 54 | + // them here is what makes both features actually run; expiry carries its | |
| 55 | + // own activation floor so an existing site cannot mass-cancel a backlog. | |
| 56 | + add_action('init', [BookingCronService::class, 'registerMaintenanceCrons']); | |
| 57 | + add_action('yatra_booking_expiry', [BookingCronService::class, 'expirePendingBookings']); | |
| 58 | + add_action('yatra_booking_reminder', [BookingCronService::class, 'sendBookingReminders']); | |
| 27 | 59 | } |
| 28 | 60 | } |