PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.6
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.6
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
← All changes | app/Services/Reminders/SubscriptionReminderService.php +13 -0 1.6.2 → 1.6.6 View file →
@@ -4,8 +4,9 @@
4 4
5 5 use FluentCart\App\Helpers\Status;
6 6 use FluentCart\App\Models\Subscription;
7 7 use FluentCart\App\Models\SubscriptionMeta;
8 +use FluentCart\App\Services\Payments\SubscriptionHelper;
8 9 use FluentCart\Framework\Support\Arr;
9 10
10 11 class SubscriptionReminderService extends ReminderService
11 12 {
@@ -111,8 +112,12 @@
111 112 if (!$this->isTrialSubscription($subscription) || !$subscription->next_billing_date) {
112 113 return false;
113 114 }
114 115
116 + if (!$this->isEligible($subscription)) {
117 + return false;
118 + }
119 +
115 120 $state = $this->normalizeReminderState($subscription->getMeta(static::TRIAL_META_KEY, []));
116 121 if ($this->isStageAlreadySent($state, $cycleKey, $stage)) {
117 122 return false;
118 123 }
@@ -184,8 +189,9 @@
184 189 $batchSize = $this->getScanBatchSize();
185 190
186 191 while (!$this->isRuntimeExpired($startedAt, $maxRuntime)) {
187 192 $subscriptions = Subscription::query()
193 + ->with('order')
188 194 ->where('id', '>', $lastId)
189 195 ->whereNotNull('next_billing_date')
190 196 ->whereIn('status', $this->getReminderStatuses())
191 197 ->orderBy('id', 'ASC')
@@ -608,8 +614,15 @@
608 614 */
609 615
610 616 protected function isEligible(Subscription $subscription): bool
611 617 {
618 + // Live subscription on a test-mode store (or vice versa): don't email —
619 + // mode lives on the parent order. Checked at both scan and send time so
620 + // pre-queued actions copied to a clone are also caught.
621 + if ($subscription->order && !SubscriptionHelper::canProcessInMode($subscription->order->mode)) {
622 + return false;
623 + }
624 +
612 625 if (!in_array($subscription->status, $this->getReminderStatuses(), true)) {
613 626 return false;
614 627 }
615 628