PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.15
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.15
6.2.15 6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 All 197 releases
← All changes | app/Services/FormBuilder/Notifications/EmailNotificationActions.php +25 -11 6.2.10 → 6.2.15 View file →
@@ -4,9 +4,8 @@
4 4
5 5 defined('ABSPATH') or die;
6 6
7 7 use FluentForm\App\Helpers\Helper;
8 -use FluentForm\App\Modules\Form\FormFieldsParser;
9 8 use FluentForm\App\Services\FormBuilder\ShortCodeParser;
10 9 use FluentForm\Framework\Foundation\Application;
11 10 use FluentForm\Framework\Helpers\ArrayHelper;
12 11
@@ -84,18 +83,13 @@
84 83 }
85 84
86 85 public function notify($feed, $formData, $entry, $form)
87 86 {
88 - // If this is a payment form and the feed is configured to run on payment_success,
89 - // then do not send while the submission's payment status is still pending.
90 - if (isset($form->has_payment) && $form->has_payment) {
91 - if (FormFieldsParser::hasElement($form, 'payment_method')) {
92 - $isTriggerOnPaymentSuccess = ArrayHelper::get($feed, 'processedValues.feed_trigger_event') === 'payment_success';
93 - $isPaymentPending = isset($entry->payment_status) && $entry->payment_status === 'pending';
94 - if ($isTriggerOnPaymentSuccess && $isPaymentPending) {
95 - return;
96 - }
97 - }
87 + // A payment_success email asserts a settled charge, so gate it on the payment status
88 + // for every payment form -- not only those with a Payment Method field.
89 + $isTriggerOnPaymentSuccess = ArrayHelper::get($feed, 'processedValues.feed_trigger_event') === 'payment_success';
90 + if (!empty($form->has_payment) && $isTriggerOnPaymentSuccess && !$this->paymentSucceeded($entry, $form)) {
91 + return;
98 92 }
99 93
100 94 $notifier = $this->app->make(
101 95 'FluentForm\App\Services\FormBuilder\Notifications\EmailNotification'
@@ -107,8 +101,28 @@
107 101 $emailData['attachments'] = $emailAttachments;
108 102 }
109 103
110 104 $notifier->notify($emailData, $formData, $form, $entry->id);
105 + }
106 +
107 + // Whether a payment_success trigger may fire for this entry.
108 + protected function paymentSucceeded($entry, $form)
109 + {
110 + $paymentStatus = is_null($entry->payment_status ?? null) ? '' : (string) $entry->payment_status;
111 +
112 + // Settled → a custom/settled status a gateway registered still fires; it is only the
113 + // known-unsettled ones that defer.
114 + if ('' !== $paymentStatus) {
115 + $unsettledStatuses = apply_filters('fluentform/unsettled_payment_statuses', [
116 + 'pending', 'failed', 'requires_review', 'cancelled', 'refunded', 'partially-refunded',
117 + ]);
118 + return !in_array($paymentStatus, $unsettledStatuses, true);
119 + }
120 +
121 + // Empty status is a $0 order: fulfil a coupon-zeroed purchase, not an omitted or zeroed input.
122 + $isFreeOrder = 'yes' === Helper::getSubmissionMeta($entry->id, '_ff_zero_total_free_order');
123 +
124 + return (bool) apply_filters('fluentform/send_payment_success_on_zero_total', $isFreeOrder, $entry, $form);
111 125 }
112 126
113 127 /**
114 128 * @param $emailData