PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.2
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.2
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / app / Modules / StoreManagedRenewal / Services / RenewalScheduler.php

RenewalScheduler.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.2, at app/Modules/StoreManagedRenewal/Services/RenewalScheduler.php

63 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Modules\StoreManagedRenewal\Services;
4
5 class RenewalScheduler
6 {
7 /**
8 * Register the scheduler hook for hourly processing
9 */
10 public function register()
11 {
12 add_action('fluent_cart/scheduler/hourly_tasks', [$this, 'handle'], 10);
13 }
14
15 /**
16 * Handle the hourly task to process due subscriptions, overdue invoices, and reminders
17 */
18 public function handle()
19 {
20 // 1. Create renewal invoices for due subscriptions
21 $results = RenewalService::processDueSubscriptions(20);
22
23 if ($results['processed'] > 0 || $results['failed'] > 0) {
24 fluent_cart_error_log(
25 'Renewal Scheduler Results',
26 sprintf(
27 'Processed: %d, Failed: %d',
28 $results['processed'],
29 $results['failed']
30 )
31 );
32
33 if (!empty($results['errors'])) {
34 foreach ($results['errors'] as $error) {
35 fluent_cart_error_log(
36 'Renewal Scheduler Error',
37 sprintf(
38 'Subscription ID: %d, Error: %s',
39 $error['subscription_id'],
40 $error['error']
41 )
42 );
43 }
44 }
45 }
46
47 // 2. Process overdue invoices — transition subscriptions past_due → expired
48 $overdueResults = RenewalService::processOverdueRenewals(20);
49
50 if ($overdueResults['past_due'] > 0 || $overdueResults['expired'] > 0) {
51 fluent_cart_error_log(
52 'Overdue Renewal Processing Results',
53 sprintf(
54 'Marked %d subscription(s) as past due, %d as expired',
55 $overdueResults['past_due'],
56 $overdueResults['expired']
57 )
58 );
59 }
60
61 }
62 }
63