Skip to content

Commit

Permalink
gpnf-delay-child-notifications-for-parent-payment.php: Send notific…
Browse files Browse the repository at this point in the history
…ation if no payment status for parent entry.
  • Loading branch information
malayladu committed Dec 30, 2024
1 parent 30ce736 commit 780eec8
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@ public function init() {

public function gpnf_should_send_notification( $should_send_notification, $notification, $context, $parent_form, $nested_form_field, $entry, $child_form ) {
if ( $context === 'parent' && $this->is_applicable_form( $parent_form['id'] ) ) {
$parent_entry = GFAPI::get_entry( rgar( $entry, 'gpnf_entry_parent' ) );
$should_send_notification = in_array( rgar( $parent_entry, 'payment_status' ), array( 'Paid', 'Active' ), true );
$parent_entry = GFAPI::get_entry( rgar( $entry, 'gpnf_entry_parent' ) );
$payment_status = rgar( $parent_entry, 'payment_status', '' );

// If no payment for parent entry, we should send the notification.
if ( empty( $payment_status ) ) {
return true;
}

$should_send_notification = in_array( $payment_status, array( 'Paid', 'Active' ), true );
}

return $should_send_notification;

}

public function gform_post_payment_completed( $entry ) {
Expand Down

0 comments on commit 780eec8

Please sign in to comment.