| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; // Exit if accessed directly |
| 5 |
} |
| 6 |
$reports = new Merchant_Analytics_Data_Reports(); |
| 7 |
$date_ranges = $reports->get_last_and_previous_7_days_ranges(); |
| 8 |
$campaigns_table = $reports->get_top_performing_campaigns( $date_ranges['recent_period'] ); |
| 9 |
$overview_data = $reports->main_analytics_cards_report(); |
| 10 |
|
| 11 |
/** |
| 12 |
* Hook: merchant_analytics_page_before. |
| 13 |
* |
| 14 |
* @hooked merchant_analytics_page_before - 10 |
| 15 |
* |
| 16 |
* @since 2.0 |
| 17 |
*/ |
| 18 |
do_action( 'merchant_analytics_page_before', $reports, $date_ranges ); |
| 19 |
require_once MERCHANT_DIR . 'admin/components/analytics-overview.php'; ?> |
| 20 |
<div class="merchant-analytics-section revenue-chart-section"> |
| 21 |
<div class="chart-head"> |
| 22 |
<div class="head-wrapper"> |
| 23 |
<div class="title"> |
| 24 |
<span class="title-text"><?php |
| 25 |
esc_html_e( 'Daily added revenue by Merchant', 'merchant' ); ?></span> |
| 26 |
</div> |
| 27 |
<div class="date-range"> |
| 28 |
<span class="merchant-analytics-loading-spinner"></span> |
| 29 |
<span class="single-date-range" data-title="<?php echo esc_attr__( 'Date:', 'merchant' ); ?>"> |
| 30 |
<input type="text" class="date-range-input" readonly value="<?php |
| 31 |
echo esc_attr( implode( ' - ', array_values( $date_ranges['recent_period'] ) ) ) ?>" placeholder="<?php |
| 32 |
esc_attr_e( 'Select date range', 'merchant' ); ?>"> |
| 33 |
</span> |
| 34 |
</div> |
| 35 |
</div> |
| 36 |
</div> |
| 37 |
<div class="chart" data-period="<?php |
| 38 |
echo esc_attr( wp_json_encode( $reports->get_revenue_chart_report( $date_ranges['recent_period']['start'], $date_ranges['recent_period']['end'] ) ) ) |
| 39 |
?>"></div> |
| 40 |
</div> |
| 41 |
<?php |
| 42 |
/** |
| 43 |
* Hook: merchant_analytics_page_between_revenue_and_aov. |
| 44 |
* |
| 45 |
* @hooked merchant_analytics_page_between_revenue_and_aov - 10 |
| 46 |
* |
| 47 |
* @since 2.0 |
| 48 |
*/ |
| 49 |
do_action( 'merchant_analytics_page_between_revenue_and_aov', $reports, $date_ranges ); ?> |
| 50 |
<div class="merchant-analytics-section aov-chart-section"> |
| 51 |
<div class="chart-head"> |
| 52 |
<div class="head-wrapper"> |
| 53 |
<div class="title"> |
| 54 |
<span class="title-text"><?php |
| 55 |
esc_html_e( 'Average order value', 'merchant' ); ?></span> |
| 56 |
</div> |
| 57 |
<div class="date-range"> |
| 58 |
<span class="merchant-analytics-loading-spinner"></span> |
| 59 |
<span class="single-date-range" data-title="<?php echo esc_attr__( 'Date:', 'merchant' ); ?>"> |
| 60 |
<input type="text" class="date-range-input" readonly value="<?php |
| 61 |
echo esc_attr( implode( ' - ', array_values( $date_ranges['recent_period'] ) ) ) ?>" placeholder="<?php |
| 62 |
esc_attr_e( 'Select date range', 'merchant' ); ?>"> |
| 63 |
</span> |
| 64 |
</div> |
| 65 |
</div> |
| 66 |
</div> |
| 67 |
<div class="chart" data-period="<?php |
| 68 |
echo esc_attr( wp_json_encode( $reports->get_aov_chart_report( $date_ranges['recent_period']['start'], $date_ranges['recent_period']['end'] ) ) ) |
| 69 |
?>"></div> |
| 70 |
</div> |
| 71 |
<?php |
| 72 |
/** |
| 73 |
* Hook: merchant_analytics_page_between_aov_and_impressions. |
| 74 |
* |
| 75 |
* @hooked merchant_analytics_page_between_aov_and_impressions - 10 |
| 76 |
* |
| 77 |
* @since 2.0 |
| 78 |
*/ |
| 79 |
do_action( 'merchant_analytics_page_between_aov_and_impressions', $reports, $date_ranges ); ?> |
| 80 |
<div class="merchant-analytics-section impressions-chart-section"> |
| 81 |
<div class="chart-head"> |
| 82 |
<div class="head-wrapper"> |
| 83 |
<div class="title"> |
| 84 |
<span class="title-text"><?php |
| 85 |
esc_html_e( 'Number of impressions', 'merchant' ); ?></span> |
| 86 |
</div> |
| 87 |
<div class="date-range"> |
| 88 |
<span class="merchant-analytics-loading-spinner"></span> |
| 89 |
<span class="single-date-range" data-title="<?php echo esc_attr__( 'Date:', 'merchant' ); ?>"> |
| 90 |
<input type="text" class="date-range-input" readonly value="<?php |
| 91 |
echo esc_attr( implode( ' - ', array_values( $date_ranges['recent_period'] ) ) ) ?>" placeholder="<?php |
| 92 |
esc_attr_e( 'Select date range', 'merchant' ); ?>"> |
| 93 |
</span> |
| 94 |
</div> |
| 95 |
</div> |
| 96 |
</div> |
| 97 |
<div class="chart" data-period="<?php |
| 98 |
echo esc_attr( wp_json_encode( $reports->get_impressions_chart_report( $date_ranges['recent_period']['start'], $date_ranges['recent_period']['end'] ) ) ) |
| 99 |
?>"></div> |
| 100 |
</div> |
| 101 |
<?php |
| 102 |
/** |
| 103 |
* Hook: merchant_analytics_page_between_impressions_and_campaigns_table. |
| 104 |
* |
| 105 |
* @hooked merchant_analytics_page_between_impressions_and_campaigns_table - 10 |
| 106 |
* |
| 107 |
* @since 2.0 |
| 108 |
*/ |
| 109 |
do_action( 'merchant_analytics_page_between_impressions_and_campaigns_table', $reports, $date_ranges ); |
| 110 |
?> |
| 111 |
<div class="merchant-analytics-section campaigns-table"> |
| 112 |
<div class="overview-head"> |
| 113 |
<div class="head-wrapper"> |
| 114 |
<div class="title"> |
| 115 |
<span class="title-text"><?php |
| 116 |
esc_html_e( 'Top performing campaigns', 'merchant' ); ?></span> |
| 117 |
</div> |
| 118 |
<div class="date-range"> |
| 119 |
<span class="merchant-analytics-loading-spinner"></span> |
| 120 |
<span class="first-date-range first-date-range-top-campaigns" data-title="<?php echo esc_attr__( 'Date:', 'merchant' ); ?>"> |
| 121 |
<input type="text" class="date-range-input" readonly value="<?php |
| 122 |
echo esc_attr( implode( ' - ', array_values( $date_ranges['recent_period'] ) ) ) ?>" placeholder="<?php |
| 123 |
esc_attr_e( 'Date range', 'merchant' ); ?>"> |
| 124 |
</span> |
| 125 |
</div> |
| 126 |
</div> |
| 127 |
</div> |
| 128 |
<div class="campaigns-table-wrapper"> |
| 129 |
<table> |
| 130 |
<thead> |
| 131 |
<tr> |
| 132 |
<th class="module" data-sort="string"><?php esc_html_e('Modules', 'merchant'); ?></th> |
| 133 |
<th class="impressions" data-sort="int"><?php esc_html_e('Impressions', 'merchant'); ?></th> |
| 134 |
<th class="clicks" data-sort="int"><?php esc_html_e('Clicks', 'merchant'); ?></th> |
| 135 |
<th class="ctr" data-sort="float"><?php esc_html_e('CTR', 'merchant'); ?></th> |
| 136 |
<th class="orders" data-sort="int"><?php esc_html_e('Orders', 'merchant'); ?></th> |
| 137 |
<th class="revenue" data-sort="float"><?php esc_html_e('Revenue', 'merchant'); ?></th> |
| 138 |
</tr> |
| 139 |
</thead> |
| 140 |
<tbody> |
| 141 |
<?php |
| 142 |
if ( ! empty( $campaigns_table ) ) { |
| 143 |
foreach ( $campaigns_table as $campaign ) { |
| 144 |
?> |
| 145 |
<tr> |
| 146 |
<td><?php |
| 147 |
echo esc_html( $campaign['campaign_info']['module_name'] . ': ' . $campaign['campaign_info']['campaign_title'] ) ?></td> |
| 148 |
<td><?php |
| 149 |
echo esc_html( $campaign['impressions'] ) ?></td> |
| 150 |
<td><?php |
| 151 |
echo esc_html( $campaign['clicks'] ) ?></td> |
| 152 |
<td class="ctr"><?php |
| 153 |
echo esc_html( $campaign['ctr'] ) ?></td> |
| 154 |
<td><?php |
| 155 |
echo esc_html( $campaign['orders'] ) ?></td> |
| 156 |
<td><?php |
| 157 |
echo wp_kses( wc_price( $campaign['revenue'] ), merchant_kses_allowed_tags( array( 'all' ) ) ) ?></td> |
| 158 |
</tr> |
| 159 |
<?php |
| 160 |
} |
| 161 |
} else { |
| 162 |
?> |
| 163 |
<tr> |
| 164 |
<td colspan="6" style="text-align: center;background: #fff;font-size: 20px;padding-block: 50px;color: #101517;"><?php esc_html_e( 'No data available', 'merchant' ); ?></td> |
| 165 |
</tr> |
| 166 |
<?php |
| 167 |
} |
| 168 |
?> |
| 169 |
</tbody> |
| 170 |
</table> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
<?php |
| 174 |
/** |
| 175 |
* Hook: merchant_analytics_page_after. |
| 176 |
* |
| 177 |
* @hooked merchant_analytics_page_after - 10 |
| 178 |
* |
| 179 |
* @since 2.0 |
| 180 |
*/ |
| 181 |
do_action( 'merchant_analytics_page_after', $reports, $date_ranges ); |