PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 2.3.0
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v2.3.0
2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 1.8.1 All 42 releases
sellkit / includes / admin / components / analytics / alert / summary.php

summary.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 2.3.0, at includes/admin/components/analytics/alert/summary.php

83 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sellkit\Admin\Components\Analytics\Alert;
4
5 use Sellkit\Admin\Components\Analytics;
6 use Sellkit\Database;
7
8 defined( 'ABSPATH' ) || die();
9
10 /**
11 * Components class.
12 *
13 * @since 1.1.0
14 */
15 class Summary {
16
17 /**
18 * All valid discounts.
19 *
20 * @var $data array Discounts.
21 */
22 public $data;
23
24 /**
25 * Class instance.
26 *
27 * @since 1.1.0
28 * @var Summary
29 */
30 private static $instance = null;
31
32 /**
33 * Gets class instance.
34 *
35 * @since 1.1.0
36 * @return Summary
37 */
38 public static function get_instance() {
39 if ( null === self::$instance ) {
40 self::$instance = new self();
41 }
42
43 return self::$instance;
44 }
45
46 /**
47 * Class constructor.
48 *
49 * @since 1.1.0
50 */
51 public function __construct() {
52 $this->set_alert_details();
53 }
54
55 /**
56 * Set discount details.
57 *
58 * @since 1.1.0
59 */
60 public function set_alert_details() {
61 global $wpdb;
62
63 $rule_id = sellkit_htmlspecialchars( INPUT_GET, 'target_id' );
64
65 $start_date = time() - ( 60 * 60 * 24 * Analytics::$date_range );
66
67 $sellkit_prefix = Database::DATABASE_PREFIX;
68 $alert_table = "{$wpdb->prefix}{$sellkit_prefix}applied_alert";
69
70 // phpcs:disable
71 $query_result = $wpdb->get_results(
72 $wpdb->prepare( "SELECT SUM(impression) as impression, SUM(click) as click FROM {$alert_table}
73 where applied_at > {$start_date} and rule_id " . Analytics::target_id_condition( $rule_id ) . " %d", $rule_id ),
74 ARRAY_A );
75
76 $this->data['impression'] = ! empty( $query_result[0]['impression'] ) ? $query_result[0]['impression'] : 0;
77 $this->data['click'] = ! empty( $query_result[0]['click'] ) ? $query_result[0]['click'] : 0;
78 // phpcs:enable
79
80 $this->data['target_title'] = get_the_title( $rule_id );
81 }
82 }
83