PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.10.4
Subscriptions for WooCommerce with Stripe Recurring Payments v1.10.4
2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
subscription / includes / Admin / views / reports-preview.php

reports-preview.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.10.4, at includes/Admin/views/reports-preview.php

522 lines 27.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Reports page — interactive preview with sample data (shown when Pro is not active).
4 *
5 * @package SpringDevs\Subscription\Admin
6 */
7
8 defined( 'ABSPATH' ) || exit;
9
10 // Enqueue Chart.js
11 \SpringDevs\Subscription\Assets::enqueue_chart_js();
12
13 // ---------------------------------------------------------------------------------------------------------- //
14
15 $upgrade_url = 'https://wpsubscription.co/?utm_source=plugin&utm_medium=admin&utm_campaign=upgrade_pro';
16 $currency = function_exists( 'get_woocommerce_currency_symbol' ) ? get_woocommerce_currency_symbol() : '$';
17
18 // --- Dummy data ---
19 $dummy_metrics = array(
20 'active_subscriptions' => 142,
21 'cancelled_subscriptions' => 28,
22 'trial_subscriptions' => 19,
23 'total_products' => 8,
24 'churn_rate' => 8.4,
25 'trial_conversion_rate' => 64.7,
26 'average_subscription_value' => 24.99,
27 );
28 $dummy_revenue = array(
29 'total_revenue' => 18420.00,
30 'mrr' => 2847.00,
31 'arr' => 34164.00,
32 'net_revenue' => 17090.00,
33 );
34 $dummy_revenue_at_risk = 580.00;
35 $dummy_trials = array(
36 'total_trials' => 47,
37 'converted_trials' => 31,
38 'active_trials' => 19,
39 'trial_revenue' => 2240.00,
40 );
41 $dummy_popular = array(
42 array(
43 'product_name' => 'Monthly Wellness Box',
44 'subscription_count' => 56,
45 'total_revenue' => 6720.00,
46 'average_revenue' => 120.00,
47 ),
48 array(
49 'product_name' => 'Annual Premium Plan',
50 'subscription_count' => 38,
51 'total_revenue' => 7220.00,
52 'average_revenue' => 190.00,
53 ),
54 array(
55 'product_name' => 'Basic Weekly Kit',
56 'subscription_count' => 29,
57 'total_revenue' => 2320.00,
58 'average_revenue' => 80.00,
59 ),
60 array(
61 'product_name' => 'Pro Content Access',
62 'subscription_count' => 19,
63 'total_revenue' => 1140.00,
64 'average_revenue' => 60.00,
65 ),
66 array(
67 'product_name' => 'Starter Bundle',
68 'subscription_count' => 12,
69 'total_revenue' => 480.00,
70 'average_revenue' => 40.00,
71 ),
72 );
73 $dummy_trends = array(
74 array(
75 'label' => 'Jan',
76 'revenue' => 2200,
77 'active' => 118,
78 'total' => 130,
79 'cancelled' => 5,
80 'trials' => 12,
81 'conversions' => 8,
82 ),
83 array(
84 'label' => 'Feb',
85 'revenue' => 2380,
86 'active' => 122,
87 'total' => 135,
88 'cancelled' => 4,
89 'trials' => 14,
90 'conversions' => 9,
91 ),
92 array(
93 'label' => 'Mar',
94 'revenue' => 2510,
95 'active' => 126,
96 'total' => 140,
97 'cancelled' => 6,
98 'trials' => 16,
99 'conversions' => 11,
100 ),
101 array(
102 'label' => 'Apr',
103 'revenue' => 2650,
104 'active' => 130,
105 'total' => 144,
106 'cancelled' => 3,
107 'trials' => 18,
108 'conversions' => 12,
109 ),
110 array(
111 'label' => 'May',
112 'revenue' => 2730,
113 'active' => 134,
114 'total' => 148,
115 'cancelled' => 5,
116 'trials' => 17,
117 'conversions' => 14,
118 ),
119 array(
120 'label' => 'Jun',
121 'revenue' => 2847,
122 'active' => 142,
123 'total' => 155,
124 'cancelled' => 4,
125 'trials' => 19,
126 'conversions' => 13,
127 ),
128 );
129
130 if ( ! function_exists( 'subscrpt_preview_format_price' ) ) {
131 /**
132 * Format a dummy price for display in the preview.
133 *
134 * @param float $amount Amount to format.
135 * @return string Formatted price HTML.
136 */
137 function subscrpt_preview_format_price( float $amount ): string {
138 return function_exists( 'wc_price' ) ? wc_price( $amount ) : esc_html( '$' . number_format( $amount, 2 ) );
139 }
140 }
141 ?>
142
143 <!-- Disclaimer banner -->
144 <div style="max-width:1240px;margin:20px auto 0;padding:0;">
145 <div style="background:#fffbeb;border:1px solid #fcd34d;border-radius:8px;padding:12px 16px;display:flex;align-items:flex-start;gap:10px;">
146 <svg width="18" height="18" fill="none" viewBox="0 0 24 24" stroke="#d97706" style="flex-shrink:0;margin-top:1px;" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
147 <p style="margin:0;font-size:13px;color:#92400e;line-height:1.5;">
148 <strong><?php esc_html_e( 'Preview with sample data.', 'subscription' ); ?></strong>
149 <?php esc_html_e( 'This page shows example data to illustrate the feature.', 'subscription' ); ?>
150 <a href="<?php echo esc_url( $upgrade_url ); ?>" target="_blank" rel="noreferrer noopener" style="color:#b45309;font-weight:600;text-decoration:underline;"><?php esc_html_e( 'Upgrade to Pro', 'subscription' ); ?></a>
151 <?php esc_html_e( 'to unlock real subscription analytics.', 'subscription' ); ?>
152 </p>
153 </div>
154 </div>
155
156 <!-- Page header -->
157 <div style="max-width:1240px;margin:20px auto 0;padding:0 0 20px;">
158 <div style="display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:12px;">
159 <div>
160 <h1 style="font-size:1.375rem;font-weight:700;color:var(--wpsubs-text);margin:0 0 6px;line-height:1.2;"><?php esc_html_e( 'Subscription Reports', 'subscription' ); ?></h1>
161 <p style="font-size:13px;color:var(--wpsubs-text-muted);margin:0;line-height:1.5;"><?php esc_html_e( 'Data-driven insights for your subscription business.', 'subscription' ); ?></p>
162 </div>
163 <div style="display:flex;align-items:center;gap:8px;flex-shrink:0;padding-top:4px;">
164 <button type="button" class="wpsubs-btn wpsubs-btn--outline" style="height:28px;padding:0 10px;font-size:12px;cursor:not-allowed;opacity:0.6;" disabled>
165 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true" style="flex-shrink:0;"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" /></svg>
166 <?php esc_html_e( 'Refresh', 'subscription' ); ?>
167 </button>
168 </div>
169 </div>
170 <div style="border-top:1px dashed #d0d3d7;"></div>
171 </div>
172
173 <!-- Page content -->
174 <div class="wp-subscription-admin-content list-page subscrpt-subs-list" style="margin-top:0;">
175
176 <!-- KPI stat cards -->
177 <div style="display:grid;grid-template-columns:repeat(5,1fr);gap:16px;margin-bottom:16px;">
178
179 <div style="border:1px solid var(--wpsubs-border);border-radius:12px;padding:20px;background:var(--wpsubs-surface);">
180 <div style="display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:8px;">
181 <div style="font-size:1.875rem;font-weight:700;color:#111827;line-height:1;"><?php echo esc_html( number_format_i18n( $dummy_metrics['active_subscriptions'] ) ); ?></div>
182 <span style="display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:8px;background:#eef2ff;flex-shrink:0;color:#6366f1;">
183 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" /></svg>
184 </span>
185 </div>
186 <div style="font-size:14px;font-weight:500;color:var(--wpsubs-text);"><?php esc_html_e( 'Active Subscriptions', 'subscription' ); ?></div>
187 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Recurring revenue base', 'subscription' ); ?></div>
188 </div>
189
190 <div style="border:1px solid var(--wpsubs-border);border-radius:12px;padding:20px;background:var(--wpsubs-surface);">
191 <div style="display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:8px;">
192 <div style="font-size:1.875rem;font-weight:700;color:#111827;line-height:1;"><?php echo wp_kses_post( subscrpt_preview_format_price( $dummy_revenue['mrr'] ) ); ?></div>
193 <span style="display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:8px;background:#f0fdf4;flex-shrink:0;color:#16a34a;">
194 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
195 </span>
196 </div>
197 <div style="font-size:14px;font-weight:500;color:var(--wpsubs-text);"><?php esc_html_e( 'Monthly Recurring Revenue', 'subscription' ); ?></div>
198 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Predictable monthly income', 'subscription' ); ?></div>
199 </div>
200
201 <div style="border:1px solid var(--wpsubs-border);border-radius:12px;padding:20px;background:var(--wpsubs-surface);">
202 <div style="display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:8px;">
203 <div style="font-size:1.875rem;font-weight:700;color:#ef4444;line-height:1;"><?php echo wp_kses_post( subscrpt_preview_format_price( $dummy_revenue_at_risk ) ); ?></div>
204 <span style="display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:8px;background:#fef2f2;flex-shrink:0;color:#ef4444;">
205 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" /></svg>
206 </span>
207 </div>
208 <div style="font-size:14px;font-weight:500;color:var(--wpsubs-text);"><?php esc_html_e( 'Revenue at Risk', 'subscription' ); ?></div>
209 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Needs attention', 'subscription' ); ?></div>
210 </div>
211
212 <div style="border:1px solid var(--wpsubs-border);border-radius:12px;padding:20px;background:var(--wpsubs-surface);">
213 <div style="display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:8px;">
214 <div style="font-size:1.875rem;font-weight:700;color:#111827;line-height:1;"><?php echo esc_html( number_format_i18n( $dummy_metrics['churn_rate'], 1 ) ); ?>%</div>
215 <span style="display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:8px;background:#fff7ed;flex-shrink:0;color:#f97316;">
216 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 17h8m0 0V9m0 8l-8-8-4 4-6-6" /></svg>
217 </span>
218 </div>
219 <div style="font-size:14px;font-weight:500;color:var(--wpsubs-text);"><?php esc_html_e( 'Churn Rate', 'subscription' ); ?></div>
220 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Customer retention indicator', 'subscription' ); ?></div>
221 </div>
222
223 <div style="border:1px solid var(--wpsubs-border);border-radius:12px;padding:20px;background:var(--wpsubs-surface);">
224 <div style="display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:8px;">
225 <div style="font-size:1.875rem;font-weight:700;color:#111827;line-height:1;"><?php echo esc_html( number_format_i18n( $dummy_metrics['trial_conversion_rate'], 1 ) ); ?>%</div>
226 <span style="display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:8px;background:#faf5ff;flex-shrink:0;color:#8b5cf6;">
227 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
228 </span>
229 </div>
230 <div style="font-size:14px;font-weight:500;color:var(--wpsubs-text);"><?php esc_html_e( 'Trial Conversion', 'subscription' ); ?></div>
231 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Trial to paid success', 'subscription' ); ?></div>
232 </div>
233
234 </div>
235
236 <!-- Revenue & Trends chart -->
237 <div class="wpsubs-table-card" style="margin-bottom:16px;">
238 <div style="padding:16px 20px;border-bottom:1px solid var(--wpsubs-border);">
239 <h2 style="font-size:13px;font-weight:600;color:var(--wpsubs-text-muted);text-transform:uppercase;letter-spacing:0.07em;margin:0;"><?php esc_html_e( 'Revenue & Subscription Trends', 'subscription' ); ?></h2>
240 </div>
241 <div style="padding:20px;display:grid;grid-template-columns:1fr 260px;gap:24px;align-items:start;">
242 <div>
243 <canvas id="subscrpt-preview-trends-chart" style="width:100%;height:280px;"></canvas>
244 </div>
245 <div>
246 <p style="font-size:12px;font-weight:600;color:var(--wpsubs-text-muted);text-transform:uppercase;letter-spacing:0.07em;margin:0 0 10px;"><?php esc_html_e( 'Quick Insights', 'subscription' ); ?></p>
247 <div style="display:flex;flex-direction:column;gap:10px;">
248 <div style="padding:12px;border-radius:8px;border:1px solid #86efac;background:#f0fdf4;">
249 <div style="font-size:12px;font-weight:600;color:#166534;margin-bottom:4px;"><?php esc_html_e( 'Revenue Growth', 'subscription' ); ?></div>
250 <div style="font-size:12px;color:#15803d;"><?php esc_html_e( 'MRR is growing steadily — great foundation!', 'subscription' ); ?></div>
251 </div>
252 <div style="padding:12px;border-radius:8px;border:1px solid var(--wpsubs-border);background:var(--wpsubs-surface-muted);">
253 <div style="font-size:12px;font-weight:600;color:var(--wpsubs-text);margin-bottom:4px;"><?php esc_html_e( 'Pro Tip', 'subscription' ); ?></div>
254 <div style="font-size:12px;color:var(--wpsubs-text-muted);"><?php esc_html_e( 'Focus on top-performing products and optimise trial conversions.', 'subscription' ); ?></div>
255 </div>
256 </div>
257 </div>
258 </div>
259 </div>
260
261 <!-- Performance metrics: 3 cards -->
262 <div style="display:grid;grid-template-columns:repeat(3,1fr);gap:16px;margin-bottom:16px;">
263
264 <div class="wpsubs-table-card">
265 <div style="padding:16px 20px;border-bottom:1px solid var(--wpsubs-border);">
266 <h2 style="font-size:13px;font-weight:600;color:var(--wpsubs-text-muted);text-transform:uppercase;letter-spacing:0.07em;margin:0;"><?php esc_html_e( 'Revenue Performance', 'subscription' ); ?></h2>
267 </div>
268 <div style="padding:20px;display:grid;grid-template-columns:1fr 1fr;gap:16px;">
269 <div>
270 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo wp_kses_post( subscrpt_preview_format_price( $dummy_revenue['total_revenue'] ) ); ?></div>
271 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Total Revenue', 'subscription' ); ?></div>
272 </div>
273 <div>
274 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo wp_kses_post( subscrpt_preview_format_price( $dummy_revenue['arr'] ) ); ?></div>
275 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Annual Recurring', 'subscription' ); ?></div>
276 </div>
277 <div>
278 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo wp_kses_post( subscrpt_preview_format_price( $dummy_revenue['net_revenue'] ) ); ?></div>
279 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Net Revenue', 'subscription' ); ?></div>
280 </div>
281 <div>
282 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo wp_kses_post( subscrpt_preview_format_price( $dummy_metrics['average_subscription_value'] ) ); ?></div>
283 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Avg. Value', 'subscription' ); ?></div>
284 </div>
285 </div>
286 </div>
287
288 <div class="wpsubs-table-card">
289 <div style="padding:16px 20px;border-bottom:1px solid var(--wpsubs-border);">
290 <h2 style="font-size:13px;font-weight:600;color:var(--wpsubs-text-muted);text-transform:uppercase;letter-spacing:0.07em;margin:0;"><?php esc_html_e( 'Trial Performance', 'subscription' ); ?></h2>
291 </div>
292 <div style="padding:20px;display:grid;grid-template-columns:1fr 1fr;gap:16px;">
293 <div>
294 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo esc_html( number_format_i18n( $dummy_trials['total_trials'] ) ); ?></div>
295 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Total Trials', 'subscription' ); ?></div>
296 </div>
297 <div>
298 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo esc_html( number_format_i18n( $dummy_trials['converted_trials'] ) ); ?></div>
299 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Converted', 'subscription' ); ?></div>
300 </div>
301 <div>
302 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo esc_html( number_format_i18n( $dummy_trials['active_trials'] ) ); ?></div>
303 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Active Trials', 'subscription' ); ?></div>
304 </div>
305 <div>
306 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo wp_kses_post( subscrpt_preview_format_price( $dummy_trials['trial_revenue'] ) ); ?></div>
307 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Trial Revenue', 'subscription' ); ?></div>
308 </div>
309 </div>
310 </div>
311
312 <div class="wpsubs-table-card">
313 <div style="padding:16px 20px;border-bottom:1px solid var(--wpsubs-border);">
314 <h2 style="font-size:13px;font-weight:600;color:var(--wpsubs-text-muted);text-transform:uppercase;letter-spacing:0.07em;margin:0;"><?php esc_html_e( 'Subscription Breakdown', 'subscription' ); ?></h2>
315 </div>
316 <div style="padding:20px;display:grid;grid-template-columns:1fr 1fr;gap:16px;">
317 <div>
318 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo esc_html( number_format_i18n( $dummy_metrics['active_subscriptions'] ) ); ?></div>
319 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Active', 'subscription' ); ?></div>
320 </div>
321 <div>
322 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo esc_html( number_format_i18n( $dummy_metrics['cancelled_subscriptions'] ) ); ?></div>
323 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Cancelled', 'subscription' ); ?></div>
324 </div>
325 <div>
326 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo esc_html( number_format_i18n( $dummy_metrics['trial_subscriptions'] ) ); ?></div>
327 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Trials', 'subscription' ); ?></div>
328 </div>
329 <div>
330 <div style="font-size:1.125rem;font-weight:700;color:#111827;"><?php echo esc_html( number_format_i18n( $dummy_metrics['total_products'] ) ); ?></div>
331 <div style="font-size:12px;color:var(--wpsubs-text-muted);margin-top:2px;"><?php esc_html_e( 'Products', 'subscription' ); ?></div>
332 </div>
333 </div>
334 </div>
335
336 </div>
337
338 <!-- Top Products + Action Items -->
339 <div style="display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:16px;">
340
341 <div class="wpsubs-table-card">
342 <div style="padding:16px 20px;border-bottom:1px solid var(--wpsubs-border);">
343 <h2 style="font-size:13px;font-weight:600;color:var(--wpsubs-text-muted);text-transform:uppercase;letter-spacing:0.07em;margin:0;"><?php esc_html_e( 'Top Performing Products', 'subscription' ); ?></h2>
344 </div>
345 <?php foreach ( array_slice( $dummy_popular, 0, 5 ) as $index => $sub_product ) : ?>
346 <div style="display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 20px;border-bottom:1px solid var(--wpsubs-border);">
347 <div style="display:flex;align-items:center;gap:12px;min-width:0;">
348 <span style="display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:50%;background:<?php echo $index < 3 ? '#eef2ff' : 'var(--wpsubs-surface-muted)'; ?>;color:<?php echo $index < 3 ? '#6366f1' : 'var(--wpsubs-text-muted)'; ?>;font-size:11px;font-weight:700;flex-shrink:0;">
349 <?php echo esc_html( $index + 1 ); ?>
350 </span>
351 <div style="min-width:0;">
352 <div class="wpsubs-cell-title" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"><?php echo esc_html( $sub_product['product_name'] ); ?></div>
353 <div class="wpsubs-cell-id">
354 <?php
355 printf(
356 /* translators: %s: number of subscriptions */
357 esc_html__( '%s subscriptions', 'subscription' ),
358 esc_html( number_format_i18n( $sub_product['subscription_count'] ) )
359 );
360 ?>
361 </div>
362 </div>
363 </div>
364 <div style="text-align:right;flex-shrink:0;">
365 <div class="wpsubs-cell-title"><?php echo wp_kses_post( subscrpt_preview_format_price( $sub_product['total_revenue'] ) ); ?></div>
366 <div class="wpsubs-cell-id">
367 <?php
368 printf(
369 /* translators: %s: average revenue */
370 esc_html__( '%s avg', 'subscription' ),
371 wp_kses_post( subscrpt_preview_format_price( $sub_product['average_revenue'] ) )
372 );
373 ?>
374 </div>
375 </div>
376 </div>
377 <?php endforeach; ?>
378 </div>
379
380 <div class="wpsubs-table-card">
381 <div style="padding:16px 20px;border-bottom:1px solid var(--wpsubs-border);">
382 <h2 style="font-size:13px;font-weight:600;color:var(--wpsubs-text-muted);text-transform:uppercase;letter-spacing:0.07em;margin:0;"><?php esc_html_e( 'Action Items', 'subscription' ); ?></h2>
383 </div>
384 <div style="padding:16px 20px;display:flex;flex-direction:column;gap:12px;">
385 <div style="padding:14px;border-radius:8px;border:1px solid #86efac;background:#f0fdf4;">
386 <div style="font-size:13px;font-weight:600;color:#166534;margin-bottom:6px;"><?php esc_html_e( 'Best Performers', 'subscription' ); ?></div>
387 <ul style="margin:0;padding-left:16px;font-size:12px;color:#15803d;line-height:1.8;">
388 <li><?php echo esc_html( $dummy_popular[0]['product_name'] ); ?> — <?php echo wp_kses_post( subscrpt_preview_format_price( $dummy_popular[0]['total_revenue'] ) ); ?></li>
389 <li><?php echo esc_html( $dummy_popular[1]['product_name'] ); ?> — <?php echo wp_kses_post( subscrpt_preview_format_price( $dummy_popular[1]['total_revenue'] ) ); ?></li>
390 </ul>
391 </div>
392 <div style="padding:14px;border-radius:8px;border:1px solid var(--wpsubs-border);background:var(--wpsubs-surface-muted);">
393 <div style="font-size:13px;font-weight:600;color:var(--wpsubs-text);margin-bottom:6px;"><?php esc_html_e( 'Recommended Next Steps', 'subscription' ); ?></div>
394 <ul style="margin:0;padding-left:16px;font-size:12px;color:var(--wpsubs-text-muted);line-height:1.8;">
395 <li><?php esc_html_e( 'Analyse customer feedback', 'subscription' ); ?></li>
396 <li><?php esc_html_e( 'Optimise pricing strategy', 'subscription' ); ?></li>
397 <li><?php esc_html_e( 'Expand product offerings', 'subscription' ); ?></li>
398 </ul>
399 </div>
400 </div>
401 </div>
402
403 </div>
404
405 <!-- Detailed Analytics chart -->
406 <div class="wpsubs-table-card">
407 <div style="padding:16px 20px;border-bottom:1px solid var(--wpsubs-border);">
408 <h2 style="font-size:13px;font-weight:600;color:var(--wpsubs-text-muted);text-transform:uppercase;letter-spacing:0.07em;margin:0;"><?php esc_html_e( 'Detailed Analytics', 'subscription' ); ?></h2>
409 </div>
410 <div style="padding:20px;">
411 <canvas id="subscrpt-preview-detailed-chart" style="width:100%;height:360px;"></canvas>
412 </div>
413 </div>
414
415 </div>
416
417 <script>
418 document.addEventListener('DOMContentLoaded', function() {
419 var months = <?php echo wp_json_encode( array_column( $dummy_trends, 'label' ) ); ?>;
420 var revenue = <?php echo wp_json_encode( array_column( $dummy_trends, 'revenue' ) ); ?>;
421 var actives = <?php echo wp_json_encode( array_column( $dummy_trends, 'active' ) ); ?>;
422 var totals = <?php echo wp_json_encode( array_column( $dummy_trends, 'total' ) ); ?>;
423 var cancelled = <?php echo wp_json_encode( array_column( $dummy_trends, 'cancelled' ) ); ?>;
424 var trials = <?php echo wp_json_encode( array_column( $dummy_trends, 'trials' ) ); ?>;
425 var conversions = <?php echo wp_json_encode( array_column( $dummy_trends, 'conversions' ) ); ?>;
426
427 var trendsCtx = document.getElementById('subscrpt-preview-trends-chart');
428 if (trendsCtx) {
429 new Chart(trendsCtx.getContext('2d'), {
430 type: 'bar',
431 data: {
432 labels: months,
433 datasets: [
434 {
435 label: '<?php echo esc_js( __( 'Revenue', 'subscription' ) ); ?>',
436 data: revenue,
437 type: 'bar',
438 backgroundColor: 'rgba(99,102,241,0.8)',
439 borderColor: '#6366f1',
440 borderWidth: 2,
441 borderRadius: 6,
442 borderSkipped: false,
443 yAxisID: 'y1'
444 },
445 {
446 label: '<?php echo esc_js( __( 'Active Subscriptions', 'subscription' ) ); ?>',
447 data: actives,
448 type: 'line',
449 borderColor: '#22c55e',
450 backgroundColor: 'rgba(34,197,94,0.1)',
451 borderWidth: 3,
452 fill: true,
453 tension: 0.4,
454 pointRadius: 6,
455 pointHoverRadius: 9,
456 pointBackgroundColor: '#22c55e',
457 pointBorderColor: '#fff',
458 pointBorderWidth: 2,
459 yAxisID: 'y'
460 }
461 ]
462 },
463 options: {
464 responsive: true,
465 interaction: { mode: 'index', intersect: false },
466 plugins: {
467 legend: { position: 'top', labels: { usePointStyle: true, padding: 20, font: { size: 12 } } },
468 title: { display: false }
469 },
470 scales: {
471 x: { grid: { color: 'rgba(0,0,0,0.04)' }, ticks: { font: { size: 11 }, color: '#94a3b8' } },
472 y: { type: 'linear', display: true, position: 'left', beginAtZero: true, grid: { color: 'rgba(0,0,0,0.04)' }, ticks: { font: { size: 11 }, color: '#94a3b8' } },
473 y1: { type: 'linear', display: true, position: 'right', beginAtZero: true, grid: { drawOnChartArea: false }, ticks: { font: { size: 11 }, color: '#94a3b8', callback: function(v) { return '$' + v.toLocaleString(); } } }
474 }
475 }
476 });
477 }
478
479 var detailedCtx = document.getElementById('subscrpt-preview-detailed-chart');
480 if (detailedCtx) {
481 var palette = ['#6366f1','#22c55e','#ef4444','#f59e0b','#8b5cf6','#06b6d4'];
482 var bubbleData = months.map(function(month, i) {
483 return { x: i, y: totals[i], r: Math.max(5, (actives[i] / Math.max.apply(null, actives)) * 20), month: month, active: actives[i], cancelled: cancelled[i], trial: trials[i], conversion: conversions[i] };
484 });
485 new Chart(detailedCtx.getContext('2d'), {
486 type: 'bubble',
487 data: {
488 datasets: [{
489 label: '<?php echo esc_js( __( 'Subscription Performance', 'subscription' ) ); ?>',
490 data: bubbleData,
491 backgroundColor: bubbleData.map(function(_, i) { return palette[i % palette.length]; }),
492 borderColor: bubbleData.map(function(_, i) { return palette[i % palette.length]; }),
493 borderWidth: 2
494 }]
495 },
496 options: {
497 responsive: true,
498 plugins: {
499 legend: { display: false },
500 tooltip: {
501 backgroundColor: 'rgba(15,23,42,0.92)', titleColor: '#fff', bodyColor: '#cbd5e1', cornerRadius: 8, displayColors: false, padding: 12,
502 callbacks: {
503 title: function(ctx) { return ctx[0].raw.month; },
504 label: function(ctx) { var d = ctx.raw; return ['<?php echo esc_js( __( 'Total', 'subscription' ) ); ?>: ' + d.y, '<?php echo esc_js( __( 'Active', 'subscription' ) ); ?>: ' + d.active, '<?php echo esc_js( __( 'Cancelled', 'subscription' ) ); ?>: ' + d.cancelled]; }
505 }
506 }
507 },
508 scales: {
509 x: { type: 'linear', ticks: { stepSize: 1, callback: function(v) { return (v >= 0 && v < months.length) ? months[v] : ''; }, font: { size: 11 }, color: '#94a3b8' }, grid: { color: 'rgba(0,0,0,0.04)' } },
510 y: { ticks: { font: { size: 11 }, color: '#94a3b8' }, grid: { color: 'rgba(0,0,0,0.04)' } }
511 }
512 }
513 });
514 }
515 });
516 </script>
517
518 <?php
519 $modal_title = __( 'Unlock Reports', 'subscription' );
520 $modal_desc = __( 'Reports requires WPSubscription Pro. Unlock advanced features, priority support, and more with WPSubscription Pro.', 'subscription' );
521 require __DIR__ . '/pro-upgrade-modal.php';
522