From b13877caf6bb31657e17eb90226a31d65a8f98bf Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Thu, 31 Oct 2024 15:45:26 +0000 Subject: [PATCH] Camptix stats: move ticket viewing stat to separate option and avoid autoloading --- .../wp-content/plugins/camptix/camptix.php | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/public_html/wp-content/plugins/camptix/camptix.php b/public_html/wp-content/plugins/camptix/camptix.php index f28a1164f..e1272af8c 100644 --- a/public_html/wp-content/plugins/camptix/camptix.php +++ b/public_html/wp-content/plugins/camptix/camptix.php @@ -2392,6 +2392,23 @@ function update_stats( $key, $value ) { return; } + /** + * + * Increments the stat used on the ticket form. + * + * @param $key + * @return void + */ + function increment_ticket_form_stat( $key ) { + if ( $key !== 'tickets_form_unique_visitors' ) { + return; + } + $viewing_stat = get_option( 'camptix_ticket_form_stat', 0 ); + $viewing_stat++; + update_option( 'camptix_ticket_form_stat', $viewing_stat, 'no' ); + return; + } + /** * Increments a stats value. */ @@ -2482,7 +2499,7 @@ public function process_client_stats() { switch ( $_REQUEST['command'] ) { case 'increment': - $this->increment_stats( $_REQUEST['stat'] ); + $this->increment_ticket_form_stat( $_REQUEST['stat'] ); wp_send_json_success(); break; } @@ -2701,6 +2718,14 @@ function generate_revenue_report_data() { $this->update_stats( 'discounted', $totals->discounted ); $this->update_stats( 'revenue', $totals->revenue ); + $this->update_stats_multi( [ + 'sold' => $totals->sold, + 'remaining' => $totals->remaining, + 'subtotal' => $totals->sub_total, + 'discounted' => $totals->discounted, + 'revenue' => $totals->revenue, + ] ); + $results = array( 'totals' => $totals, 'actual_total' => $actual_total,