Skip to content

Conversation

@Genevieve-K
Copy link
Contributor

In my example, a donor has made 96 donations, but only 16 are completed. Only the 20 first are displayed in the donation history. Explanation: The give_count_donations_of_donor() function calls give_get_donation_stats_by_user( $user ), and $donor->purchase_count is used to count donations. However this attribute counts only completed donations, whereas in the donation history, all donations are displayed (status any). As 16 < 20, pagination is not necessary.
I suggested using $donor->payment_ids which contains all donations, and counting them.

A donor has in my example 96 donations, but only 16 are completed. Only the 20 first are displayed.
The function give_count_donations_of_donor() calls give_get_donation_stats_by_user( $user ), and $donor->purchase_count is used to count the donation. But this attr counts only the completed donations, and in the donation history, all donations are displayed (status any). 
I suggested to use $donor->payment_ids that contains all donations, and count them.
@github-actions
Copy link

github-actions bot commented Nov 8, 2025

This PR is stale because it has been open 45 days with no activity. Stale PRs will NOT be automatically closed.

@github-actions github-actions bot added the Stale label Nov 8, 2025
$stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false;

return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
return isset( $stats['donations_count'] ) ? $stats['donations_count'] : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the donation history shortcode has a status param, you might want to account for that here so the pagination works for any or completed/publish

Suggested change
return isset( $stats['donations_count'] ) ? $stats['donations_count'] : 0;
return $status === 'any' ? ($stats['donations_count'] ?? 0) : ($stats['purchases'] ?? 0)

@github-actions github-actions bot removed the Stale label Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants