PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.4.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.4.0
2.4.0 2.3.0 2.2.0 2.1.0 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 All 65 releases
← All changes | includes/Admin/views/reports-preview.php +127 -28 1.10.2 → 2.4.0 View file →
@@ -6,8 +6,13 @@
6 6 */
7 7
8 8 defined( 'ABSPATH' ) || exit;
9 9
10 +// Enqueue Chart.js
11 +\SpringDevs\Subscription\Assets::enqueue_chart_js();
12 +
13 +// ---------------------------------------------------------------------------------------------------------- //
14 +
10 15 $upgrade_url = 'https://wpsubscription.co/?utm_source=plugin&utm_medium=admin&utm_campaign=upgrade_pro';
11 16 $currency = function_exists( 'get_woocommerce_currency_symbol' ) ? get_woocommerce_currency_symbol() : '$';
12 17
13 18 // --- Dummy data ---
@@ -132,42 +137,83 @@
132 137 function subscrpt_preview_format_price( float $amount ): string {
133 138 return function_exists( 'wc_price' ) ? wc_price( $amount ) : esc_html( '$' . number_format( $amount, 2 ) );
134 139 }
135 140 }
141 +
142 +// Sample cancellation reasons, shaped exactly like Pro's real query result so
143 +// the preview and the real report render from the same structure.
144 +$dummy_cancellation_reasons = array(
145 + 'reasons' => array(
146 + array(
147 + 'reason' => __( 'Too expensive', 'subscription' ),
148 + 'count' => 14,
149 + 'percent' => 38.9,
150 + ),
151 + array(
152 + 'reason' => __( 'Missing features I need', 'subscription' ),
153 + 'count' => 9,
154 + 'percent' => 25.0,
155 + ),
156 + array(
157 + 'reason' => __( 'Found a better alternative', 'subscription' ),
158 + 'count' => 7,
159 + 'percent' => 19.4,
160 + ),
161 + array(
162 + 'reason' => __( 'No longer needed', 'subscription' ),
163 + 'count' => 4,
164 + 'percent' => 11.1,
165 + ),
166 + array(
167 + 'reason' => __( 'Technical issues', 'subscription' ),
168 + 'count' => 2,
169 + 'percent' => 5.6,
170 + ),
171 + ),
172 + 'total' => 36,
173 +);
136 174 ?>
137 175
138 -<!-- Disclaimer banner -->
139 -<div style="max-width:1240px;margin:20px auto 0;padding:0;">
140 - <div style="background:#fffbeb;border:1px solid #fcd34d;border-radius:8px;padding:12px 16px;display:flex;align-items:flex-start;gap:10px;">
141 - <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>
142 - <p style="margin:0;font-size:13px;color:#92400e;line-height:1.5;">
143 - <strong><?php esc_html_e( 'Preview with sample data.', 'subscription' ); ?></strong>
144 - <?php esc_html_e( 'This page shows example data to illustrate the feature.', 'subscription' ); ?>
145 - <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>
146 - <?php esc_html_e( 'to unlock real subscription analytics.', 'subscription' ); ?>
147 - </p>
176 +<!-- Page content -->
177 +<div class="wp-subscription-admin-content list-page">
178 +
179 + <!-- Disclaimer banner -->
180 + <div style="max-width:1240px;margin:20px auto 0;padding:0;">
181 + <div style="background:#fffbeb;border:1px solid #fcd34d;border-radius:8px;padding:12px 16px;display:flex;align-items:flex-start;gap:10px;">
182 + <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>
183 + <p style="margin:0;font-size:13px;color:#92400e;line-height:1.5;">
184 + <strong><?php esc_html_e( 'Preview with sample data.', 'subscription' ); ?></strong>
185 + <?php esc_html_e( 'This page shows example data to illustrate the feature.', 'subscription' ); ?>
186 + <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>
187 + <?php esc_html_e( 'to unlock real subscription analytics.', 'subscription' ); ?>
188 + </p>
189 + </div>
148 190 </div>
149 -</div>
150 191
151 -<!-- Page header -->
152 -<div style="max-width:1240px;margin:20px auto 0;padding:0 0 20px;">
153 - <div style="display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:12px;">
154 - <div>
155 - <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>
156 - <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>
157 - </div>
158 - <div style="display:flex;align-items:center;gap:8px;flex-shrink:0;padding-top:4px;">
159 - <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>
160 - <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>
161 - <?php esc_html_e( 'Refresh', 'subscription' ); ?>
192 + <!-- Page header -->
193 + <div style="max-width:1240px;margin:20px auto 0;">
194 + <?php
195 + wpsubs_render_page_header(
196 + array(
197 + 'title' => __( 'Subscription Reports', 'subscription' ),
198 + 'description' => __( 'Data-driven insights for your subscription business.', 'subscription' ),
199 + 'actions' => '<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><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>' . esc_html__( 'Refresh', 'subscription' ) . '</button>',
200 + )
201 + );
202 + ?>
203 + </div>
204 +
205 + <div class="wpsubs-tabs" data-tabs-query="report" style="max-width:1240px;margin:0 auto;">
206 + <div class="wpsubs-tabs__list" role="tablist">
207 + <button class="wpsubs-tabs__tab" role="tab" id="subscrpt-report-tab-overview" data-tab-key="overview" aria-controls="subscrpt-report-panel-overview" aria-selected="true">
208 + <?php esc_html_e( 'Overview', 'subscription' ); ?>
162 209 </button>
210 + <button class="wpsubs-tabs__tab" role="tab" id="subscrpt-report-tab-cancellation" data-tab-key="cancellation" aria-controls="subscrpt-report-panel-cancellation" aria-selected="false">
211 + <?php esc_html_e( 'Cancellation', 'subscription' ); ?>
212 + </button>
163 213 </div>
164 - </div>
165 - <div style="border-top:1px dashed #d0d3d7;"></div>
166 -</div>
167 214
168 -<!-- Page content -->
169 -<div class="wp-subscription-admin-content list-page subscrpt-subs-list" style="margin-top:0;">
215 + <div class="wpsubs-tab-panel" role="tabpanel" id="subscrpt-report-panel-overview" aria-labelledby="subscrpt-report-tab-overview">
170 216
171 217 <!-- KPI stat cards -->
172 218 <div style="display:grid;grid-template-columns:repeat(5,1fr);gap:16px;margin-bottom:16px;">
173 219
@@ -406,11 +452,59 @@
406 452 <canvas id="subscrpt-preview-detailed-chart" style="width:100%;height:360px;"></canvas>
407 453 </div>
408 454 </div>
409 455
456 + </div><!-- /overview panel -->
457 +
458 + <div class="wpsubs-tab-panel" role="tabpanel" id="subscrpt-report-panel-cancellation" aria-labelledby="subscrpt-report-tab-cancellation" hidden>
459 +
460 + <div class="wpsubs-table-card">
461 + <div style="padding:16px 20px;border-bottom:1px solid var(--wpsubs-border);">
462 + <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( 'Cancellation Reasons', 'subscription' ); ?></h2>
463 + <p style="font-size:12px;color:var(--wpsubs-text-muted);margin:4px 0 0;"><?php esc_html_e( 'Why customers cancelled, based on submitted feedback.', 'subscription' ); ?></p>
464 + </div>
465 + <div style="padding:10px 20px 14px;">
466 + <?php
467 + foreach ( $dummy_cancellation_reasons['reasons'] as $subscrpt_reason_row ) :
468 + $subscrpt_reason_fill = max( 2, min( 100, (float) $subscrpt_reason_row['percent'] ) );
469 + ?>
470 + <div style="display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:11px 14px;margin-bottom:6px;border-radius:8px;border:1px solid var(--wpsubs-border);background:linear-gradient(to left, var(--wpsubs-brand-light) 0, var(--wpsubs-brand-light) calc(<?php echo esc_attr( $subscrpt_reason_fill ); ?>% - 2px), var(--wpsubs-brand) calc(<?php echo esc_attr( $subscrpt_reason_fill ); ?>% - 2px), var(--wpsubs-brand) <?php echo esc_attr( $subscrpt_reason_fill ); ?>%, transparent <?php echo esc_attr( $subscrpt_reason_fill ); ?>%);">
471 + <span style="font-size:13px;font-weight:600;color:var(--wpsubs-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;"><?php echo esc_html( $subscrpt_reason_row['reason'] ); ?></span>
472 + <span style="flex-shrink:0;">
473 + <span style="font-size:14px;font-weight:700;color:var(--wpsubs-text);"><?php echo esc_html( $subscrpt_reason_row['percent'] ); ?>%</span>
474 + <span style="font-size:12px;color:var(--wpsubs-text-muted);margin-left:4px;">
475 + <?php
476 + printf(
477 + /* translators: %s: number of subscriptions. */
478 + esc_html__( '%s subs', 'subscription' ),
479 + esc_html( number_format_i18n( $subscrpt_reason_row['count'] ) )
480 + );
481 + ?>
482 + </span>
483 + </span>
484 + </div>
485 + <?php endforeach; ?>
486 + </div>
487 + <div style="padding:12px 20px;border-top:1px solid var(--wpsubs-border);font-size:12px;color:var(--wpsubs-text-muted);">
488 + <?php
489 + printf(
490 + /* translators: %s: total number of cancellations with feedback. */
491 + esc_html__( 'Total cancellations with feedback: %s', 'subscription' ),
492 + esc_html( number_format_i18n( $dummy_cancellation_reasons['total'] ) )
493 + );
494 + ?>
495 + </div>
496 + </div>
497 +
498 + <p style="margin:14px 0 0;font-size:13px;color:var(--wpsubs-text-muted);text-align:center;">
499 + <?php esc_html_e( 'Sample data. Pro reports the reasons your own customers gave.', 'subscription' ); ?>
500 + </p>
501 +
502 + </div><!-- /cancellation panel -->
503 + </div><!-- /tabs -->
504 +
410 505 </div>
411 506
412 -<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
413 507 <script>
414 508 document.addEventListener('DOMContentLoaded', function() {
415 509 var months = <?php echo wp_json_encode( array_column( $dummy_trends, 'label' ) ); ?>;
416 510 var revenue = <?php echo wp_json_encode( array_column( $dummy_trends, 'revenue' ) ); ?>;
@@ -509,4 +603,9 @@
509 603 });
510 604 }
511 605 });
512 606 </script>
607 +
608 +<?php
609 +$modal_title = __( 'Unlock Reports', 'subscription' );
610 +$modal_desc = __( 'Reports requires WPSubscription Pro. Unlock advanced features, priority support, and more with WPSubscription Pro.', 'subscription' );
611 +require __DIR__ . '/pro-upgrade-modal.php';