Skip to content

Commit 6007fb5

Browse files
committed
Fixed issue where payment details were not synced if a specificy property was set on the parent entry (rather than a full entry update).
1 parent a026d32 commit 6007fb5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

gp-nested-forms/gpnf-sync-parent-child-entry-payment-status.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin URI: https://gravitywiz.com/documentation/gravity-forms-nested-forms/
1212
* Description: Sync the payment details of child entries with their parent's.
1313
* Author: Gravity Wiz
14-
* Version: 0.2
14+
* Version: 0.3
1515
* Author URI: https://gravitywiz.com
1616
*/
1717
add_action( 'gform_after_submission', function( $entry, $form ) {
@@ -22,10 +22,10 @@
2222
gpnf_sync_child_entries_payment_details( $entry );
2323
}, 10, 2 );
2424

25-
add_action( 'gform_after_update_entry', function( $entry_id, $original_entry ) {
26-
$entry = GFAPI::get_entry( $entry_id );
27-
gpnf_sync_child_entries_payment_details( $entry );
28-
}, 10, 2 );
25+
add_action( 'gform_after_update_entry', 'gpnf_get_parent_entry_and_sync_child_entries_payment_details' );
26+
add_action( 'gform_update_payment_status', 'gpnf_get_parent_entry_and_sync_child_entries_payment_details' );
27+
add_action( 'gform_update_payment_date', 'gpnf_get_parent_entry_and_sync_child_entries_payment_details' );
28+
add_action( 'gform_update_transaction_id', 'gpnf_get_parent_entry_and_sync_child_entries_payment_details' );
2929

3030
/**
3131
* Bulk Sync Parent/Child Entry Payment Details
@@ -69,7 +69,7 @@ function gpnf_sync_child_entries_payment_details( $parent_entry ) {
6969
foreach ( $child_entries as $child_entry ) {
7070
foreach ( $sync_props as $sync_prop ) {
7171
if ( $parent_entry->$sync_prop !== $child_entry[ $sync_prop ] ) {
72-
GFAPI::update_entry_property( $child_entry['id'], $sync_prop, $parent_entry->$$sync_prop );
72+
GFAPI::update_entry_property( $child_entry['id'], $sync_prop, $parent_entry->$sync_prop );
7373
}
7474
}
7575
}
@@ -89,3 +89,10 @@ function gpnf_has_product_field( $form ) {
8989
return false;
9090
}
9191
}
92+
93+
if ( ! function_exists( 'gpnf_get_parent_entry_and_sync_child_entries_payment_details' ) ) {
94+
function gpnf_get_parent_entry_and_sync_child_entries_payment_details( $entry_id ) {
95+
$entry = GFAPI::get_entry( $entry_id );
96+
gpnf_sync_child_entries_payment_details( $entry );
97+
}
98+
}

0 commit comments

Comments
 (0)