PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
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/Email/EmailNotificationMailer.php +58 -1 1.6.1 → 1.6.5 View file →
@@ -30,14 +30,21 @@
30 30 );
31 31
32 32 }, 999, 1);
33 33 // To Admin
34 + // 999 like the rest of this file: custom smartcodes in a customised admin
35 + // body resolve against the payload as it stands when the mail is built, so
36 + // the mail has to run after everything else bound here writes its data —
37 + // integration feeds (11), FluentCRM (20), affiliate referral status (99).
38 + // Cost of running last: this hook forces every feed to run realtime, so the
39 + // mail waits on their outbound HTTP, and IntegrationEventListener catches
40 + // only \Exception — a \Error in a feed loses the mail.
34 41 add_action('fluent_cart/order_paid_done', function ($data) {
35 42 $this->mailEmailsOfEvent(
36 43 'order_paid_done',
37 44 $data
38 45 );
39 - }, 10, 1);
46 + }, 999, 1);
40 47
41 48 // to customer and admin
42 49 add_action('fluent_cart/subscription_renewed', function ($data) {
43 50 $this->mailEmailsOfEvent(
@@ -110,11 +117,30 @@
110 117 $this->mailEmailsOfEvent('renewal_reminder_due', $data);
111 118 }, 999, 1);
112 119
113 120 add_action('fluent_cart/renewal_reminder_overdue', function ($data) {
121 + // Set only by the deprecated bridge in RenewalReminderService::send():
122 + // the staged email (renewal_overdue_first/followup/final) already went
123 + // out for this payload, so mailing here would duplicate it. Direct
124 + // dispatches of this hook never carry the flag and still deliver.
125 + if (!empty(Arr::get($data, 'staged_email_dispatched'))) {
126 + return;
127 + }
114 128 $this->mailEmailsOfEvent('renewal_reminder_overdue', $data);
115 129 }, 999, 1);
116 130
131 + add_action('fluent_cart/renewal_overdue_first', function ($data) {
132 + $this->mailEmailsOfEvent('renewal_overdue_first', $data);
133 + }, 999, 1);
134 +
135 + add_action('fluent_cart/renewal_overdue_followup', function ($data) {
136 + $this->mailEmailsOfEvent('renewal_overdue_followup', $data);
137 + }, 999, 1);
138 +
139 + add_action('fluent_cart/renewal_overdue_final', function ($data) {
140 + $this->mailEmailsOfEvent('renewal_overdue_final', $data);
141 + }, 999, 1);
142 +
117 143 add_action('fluent_cart/subscription_renewal_reminder', function ($data) {
118 144 $this->mailEmailsOfEvent('subscription_renewal_reminder', $data);
119 145 }, 999, 1);
120 146
@@ -230,8 +256,16 @@
230 256 $mailer->addAttachment($pdfPath);
231 257 }
232 258 }
233 259
260 + $mailer = $this->applyMailerFilter($mailer, [
261 + 'event' => $event,
262 + 'mail_name' => $mailName,
263 + 'recipient' => Arr::get($notification, 'recipient'),
264 + 'notification' => $notification,
265 + 'data' => $data,
266 + ]);
267 +
234 268 $mailer->send(true);
235 269
236 270 // Clean up temp PDF file after sending
237 271 if ($pdfPath && file_exists($pdfPath)) {
@@ -266,13 +300,36 @@
266 300 $mailer->addAttachment($pdfPath);
267 301 }
268 302 }
269 303
304 + $mailer = $this->applyMailerFilter($mailer, [
305 + 'event' => Arr::get($notification, 'event', ''),
306 + 'mail_name' => $emailName,
307 + 'recipient' => Arr::get($notification, 'recipient'),
308 + 'notification' => $notification,
309 + 'data' => $data,
310 + ]);
311 +
270 312 $mailer->send(true);
271 313
272 314 if ($pdfPath && file_exists($pdfPath)) {
273 315 @unlink($pdfPath);
274 316 }
317 + }
318 +
319 + /**
320 + * Let third-party code adjust the fully prepared Mailer (recipients,
321 + * subject, body, attachments already set) immediately before it sends.
322 + *
323 + * @param Mailer $mailer
324 + * @param array $context event, mail_name, recipient, notification, data
325 + * @return Mailer
326 + */
327 + private function applyMailerFilter(Mailer $mailer, array $context): Mailer
328 + {
329 + $filtered = apply_filters('fluent_cart/email_notification/mailer', $mailer, $context);
330 +
331 + return $filtered instanceof Mailer ? $filtered : $mailer;
275 332 }
276 333
277 334 public function getEmailFooter(): string
278 335 {