Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: wrong donation count
Browse files Browse the repository at this point in the history
glaubersilva committed Jul 10, 2024
1 parent 48fecd9 commit 14faa94
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions includes/admin/forms/dashboard-columns.php
Original file line number Diff line number Diff line change
@@ -168,6 +168,7 @@ function give_sortable_form_columns( $columns ) {
/**
* Sorts Columns in the Forms List Table
*
* @unreleased Use the 'give_donate_form_get_sales" filter to ensure the correct donation count will be used
* @since 1.0
*
* @param array $vars Array of all the sort variables.
@@ -180,6 +181,10 @@ function give_sort_forms( $vars ) {
return $vars;
}

add_filter('give_donate_form_get_sales', function ($sales, $donationFormId) {
return (new Give\MultiFormGoals\ProgressBar\Model(['ids' => [$donationFormId]]))->getDonationCount();
}, 10, 2);

switch ( $vars['orderby'] ) {
// Check if 'orderby' is set to "sales".
case 'sales':
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@

use Give\DonationForms\V2\Models\DonationForm;
use Give\Framework\ListTable\ModelColumn;
use Give\MultiFormGoals\ProgressBar\Model as ProgressBarModel;

/**
* @since 2.24.0
@@ -38,6 +39,7 @@ public function getLabel(): string
}

/**
* @unreleased Use the 'getDonationCount()" method from progress bar model to ensure the correct donation count will be used
* @since 2.24.0
*
* @inheritDoc
@@ -46,7 +48,7 @@ public function getLabel(): string
*/
public function getCellValue($model): string
{
$totalDonations = $model->totalNumberOfDonations;
$totalDonations = (new ProgressBarModel(['ids' => [$model->id]]))->getDonationCount();

$label = $totalDonations > 0
? sprintf(

0 comments on commit 14faa94

Please sign in to comment.