Skip to content

Commit 780eec8

Browse files
committed
gpnf-delay-child-notifications-for-parent-payment.php: Send notification if no payment status for parent entry.
1 parent 30ce736 commit 780eec8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

gp-nested-forms/gpnf-delay-child-notifications-for-parent-payment.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,18 @@ public function init() {
4343

4444
public function gpnf_should_send_notification( $should_send_notification, $notification, $context, $parent_form, $nested_form_field, $entry, $child_form ) {
4545
if ( $context === 'parent' && $this->is_applicable_form( $parent_form['id'] ) ) {
46-
$parent_entry = GFAPI::get_entry( rgar( $entry, 'gpnf_entry_parent' ) );
47-
$should_send_notification = in_array( rgar( $parent_entry, 'payment_status' ), array( 'Paid', 'Active' ), true );
46+
$parent_entry = GFAPI::get_entry( rgar( $entry, 'gpnf_entry_parent' ) );
47+
$payment_status = rgar( $parent_entry, 'payment_status', '' );
48+
49+
// If no payment for parent entry, we should send the notification.
50+
if ( empty( $payment_status ) ) {
51+
return true;
52+
}
53+
54+
$should_send_notification = in_array( $payment_status, array( 'Paid', 'Active' ), true );
4855
}
4956

5057
return $should_send_notification;
51-
5258
}
5359

5460
public function gform_post_payment_completed( $entry ) {

0 commit comments

Comments
 (0)