Skip to content

Commit

Permalink
fix: donation form list progress bar in the legacy view
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubersilva committed Jun 18, 2024
1 parent c1d62b8 commit 48fecd9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions includes/forms/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
exit;
}

use Give\DonationForms\DonationQuery;
use Give\Helpers\Form\Utils as FormUtils;

/**
Expand Down Expand Up @@ -1248,15 +1249,19 @@ function give_set_form_closed_status( $form_id ) {
/**
* Show Form Goal Stats in Admin ( Listing and Detail page )
*
* @unreleased Use the 'give_get_form_earnings_stats" filter to ensure the correct value will be displayed in the form progress bar
* @since 2.19.0 Prevent divide by zero issue in goal percentage calculation logic.
*
* @param int $form_id Form ID.
*
* @since 2.1.0
*
* @param int $form_id Form ID.
*
* @return string
*/
function give_admin_form_goal_stats( $form_id ) {
add_filter('give_get_form_earnings_stats', function ($earnings, $donationFormId) {
return (new DonationQuery())->form($donationFormId)->sumAmount();
}, 10, 2);

$html = '';
$goal_stats = give_goal_progress_stats( $form_id );
Expand Down

0 comments on commit 48fecd9

Please sign in to comment.