PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.1.0
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.1.0
1.6.0 1.5.1 1.5.0 1.4.0 1.3.0 trunk 0.0.1 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0
← All changes | inc/api/forms-api.php +17 -3 trunk1.1.0 View file →
@@ -494,9 +494,23 @@
494 494 * @return array{entries: int, revenue: float} Form stats.
495 495 * @since 1.0.0
496 496 */
497 497 private function get_form_stats( $form_id ) {
498 - // Delegates to the donations table so this surface and the abilities
499 - // report the same figures from one query.
500 - return \SureDonation\Inc\Database\Tables\Donations::get_form_stats( $form_id );
498 + global $wpdb;
499 + $table = $wpdb->prefix . 'suredonation_donations';
500 +
501 + $result = $wpdb->get_row( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
502 + $wpdb->prepare(
503 + 'SELECT COUNT(*) as entries, COALESCE(SUM(amount - refunded_amount), 0) as revenue FROM %i WHERE form_id = %d AND payment_status = %s',
504 + $table,
505 + absint( $form_id ),
506 + 'completed'
507 + ),
508 + ARRAY_A
509 + );
510 +
511 + return [
512 + 'entries' => is_array( $result ) ? (int) ( $result['entries'] ?? 0 ) : 0,
513 + 'revenue' => is_array( $result ) ? (float) ( $result['revenue'] ?? 0 ) : 0,
514 + ];
501 515 }
502 516 }