diff --git a/includes/admin/forms/dashboard-columns.php b/includes/admin/forms/dashboard-columns.php index db00d57c57..30aaa96b35 100644 --- a/includes/admin/forms/dashboard-columns.php +++ b/includes/admin/forms/dashboard-columns.php @@ -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': diff --git a/src/DonationForms/V2/ListTable/Columns/DonationCountColumn.php b/src/DonationForms/V2/ListTable/Columns/DonationCountColumn.php index 9d9fe0cbc8..5f6d3e5679 100644 --- a/src/DonationForms/V2/ListTable/Columns/DonationCountColumn.php +++ b/src/DonationForms/V2/ListTable/Columns/DonationCountColumn.php @@ -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(