PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.1
1.7.1 1.7.0 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 All 51 releases
← All changes | app/Services/Email/EmailNotifications.php +13 -0 1.7.0 → 1.7.1 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2
3 3 namespace FluentCart\App\Services\Email;
4 4
5 +use FluentCart\Api\ModuleSettings;
5 6 use FluentCart\App\Models\Meta;
6 7 use FluentCart\App\Services\Cache;
7 8 use FluentCart\App\Services\TemplateService;
8 9 use FluentCart\Framework\Support\Arr;
@@ -17,12 +18,24 @@
17 18 ];
18 19
19 20 const META_KEY = 'email_notifications_config';
20 21
22 + /** The events the reviews module raises. */
23 + const REVIEW_EVENTS = ['review_created', 'review_approved_done', 'review_replied_done'];
24 +
21 25 public static function getNotifications(): array
22 26 {
23 27 $settings = static::getDefaultNotifications();
24 28 $settings = apply_filters('fluent_cart/email_notifications', $settings);
29 +
30 + // Review notifications are neither offered nor sent while the module
31 + // is off; their stored settings are kept by name.
32 + if (!ModuleSettings::isActive('reviews')) {
33 + $settings = array_filter($settings, function ($setting) {
34 + return !in_array(Arr::get($setting, 'event'), static::REVIEW_EVENTS, true);
35 + });
36 + }
37 +
25 38 $config = Arr::get(static::cachedSettings(), 'notification_config', []);
26 39
27 40 foreach ($settings as $key => &$setting) {
28 41 $setting['name'] = $key;