PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.10.0
Subscriptions for WooCommerce with Stripe Recurring Payments v1.10.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 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
subscription / includes / Admin / views / subscription-info.php

subscription-info.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.10.0, at includes/Admin/views/subscription-info.php

282 lines 12.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Subscription Info Admin View Template
4 *
5 * @package SpringDevs\Subscription\Admin
6 */
7
8 /*
9 STYLE GUIDE FOR WP SUBSCRIPTION ADMIN PAGES:
10 - Use .wp-subscription-admin-content for main content area.
11 - Use .wp-subscription-admin-box for white card/box with shadow and 6-8px border-radius.
12 - Use .widefat.wp-subscription-list-table for tables, with no outer border, only row bottom borders.
13 - Use compact table cells: font-size 14px, padding 8px 10px.
14 - Use .button, .button-primary, .button-small for actions, with rounded corners, soft backgrounds, and subtle hover.
15 - Use pill-shaped status labels (e.g., .subscrpt-active) for status.
16 - Use Georgia, serif for titles, system sans-serif for body.
17 - Keep all sections visually consistent, compact, and modern.
18 - Avoid excessive spacing or large paddings.
19 - All new UI/UX changes must follow these conventions.
20 */
21
22 // Exit if accessed directly.
23 if ( ! defined( 'ABSPATH' ) ) {
24 exit;
25 }
26
27 if ( ! isset( $post ) || ! is_object( $post ) ) {
28 global $post;
29 }
30
31 $order_id = get_post_meta( $post->ID, '_subscrpt_order_id', true );
32 $order = wc_get_order( $order_id );
33 $order_item_id = get_post_meta( $post->ID, '_subscrpt_order_item_id', true );
34 $order_item = $order ? $order->get_item( $order_item_id ) : null;
35 $product_name = $order_item ? $order_item->get_name() : '-';
36 $cost = $order_item ? SpringDevs\Subscription\Illuminate\Helper::format_price_with_order_item( get_post_meta( $post->ID, '_subscrpt_price', true ), $order_item_id ) : '-';
37 $qty = $order_item ? 'x' . $order_item->get_quantity() : '-';
38 $customer = $order ? $order->get_formatted_billing_full_name() : '-';
39 $customer_id = $order ? $order->get_customer_id() : 0;
40 $customer_url = $customer_id ? admin_url( 'user-edit.php?user_id=' . $customer_id ) : '';
41 $start_date = get_post_meta( $post->ID, '_subscrpt_start_date', true );
42 $end_date = get_post_meta( $post->ID, '_subscrpt_end_date', true );
43 $renewal_date = get_post_meta( $post->ID, '_subscrpt_next_date', true );
44 $status_obj = get_post_status_object( get_post_status( $post->ID ) );
45 $payment_method = $order ? $order->get_payment_method_title() : '-';
46 $billing_address = $order ? $order->get_formatted_billing_address() : '-';
47 $shipping_address = $order ? $order->get_formatted_shipping_address() : '-';
48
49
50 ?>
51 <div class="wp-subscription-admin-content">
52 <div class="wp-subscription-info-grid" style="display:flex;gap:28px;align-items:flex-start;flex-wrap:nowrap;">
53 <!-- Left: Main Info -->
54 <div class="wp-subscription-admin-box wp-subscription-info-left" style="box-shadow: 0 1px 3px rgb(29 35 39 / 30%);flex:1 1 50%;max-width:50%;margin:25px 0 18px 18px;">
55 <table class="widefat striped wp-subscription-list-table" style="border-radius:8px;overflow:hidden;margin-bottom:16px;">
56 <tbody>
57 <tr>
58 <th style="width:120px;padding:8px 10px;">Product</th>
59 <td style="padding:8px 10px;"><?php echo esc_html( $product_name ); ?></td>
60 </tr>
61 <tr>
62 <th style="padding:8px 10px;">Cost</th>
63 <td style="padding:8px 10px;"><?php echo wp_kses_post( $cost ); ?></td>
64 </tr>
65 <tr>
66 <th style="padding:8px 10px;">Qty</th>
67 <td style="padding:8px 10px;"><?php echo esc_html( $qty ); ?></td>
68 </tr>
69
70 <?php
71 // Display payment information if max_payments is set
72 $product_id = get_post_meta( $post->ID, '_subscrpt_product_id', true );
73 $max_payments = subscrpt_get_max_payments( $post->ID ) ?: 0;
74
75 // Get payment type information first (needed for condition)
76 $payment_type = $product_id ? get_post_meta( $product_id, '_subscrpt_payment_type', true ) : 'recurring';
77 $payment_type = $payment_type ?: 'recurring'; // Default to recurring if empty
78
79 // Also check subscription's own meta data
80 $subscription_payment_type = get_post_meta( $post->ID, '_subscrpt_payment_type', true );
81 $subscription_max_payments = get_post_meta( $post->ID, '_subscrpt_max_no_payment', true );
82
83 // Also check if this subscription has variation data
84 $variation_id = get_post_meta( $post->ID, '_subscrpt_variation_id', true );
85 if ( $variation_id ) {
86 $variation_payment_type = get_post_meta( $variation_id, '_subscrpt_payment_type', true );
87 $variation_max_payments = get_post_meta( $variation_id, '_subscrpt_max_no_payment', true );
88
89 // Use variation data if product data is not available
90 if ( empty( $payment_type ) || 'recurring' === $payment_type ) {
91 if ( ! empty( $variation_payment_type ) ) {
92 $payment_type = $variation_payment_type;
93 }
94 }
95 if ( ! $max_payments && ! empty( $variation_max_payments ) ) {
96 $max_payments = $variation_max_payments;
97 }
98 }
99
100 // Use subscription's own data if available and more specific
101 if ( ! empty( $subscription_payment_type ) ) {
102 $payment_type = $subscription_payment_type;
103 }
104 if ( ! empty( $subscription_max_payments ) ) {
105 $max_payments = $subscription_max_payments;
106 }
107
108 // Final fallback: Infer payment type from max_payments if not explicitly set
109 if ( ( empty( $payment_type ) || 'recurring' === $payment_type ) && $max_payments > 0 ) {
110 $payment_type = 'split_payment';
111 }
112
113 // Ensure max_payments is properly set for display
114 $max_payments = (int) $max_payments;
115
116 // Show Total Payments if conditions are met
117 if ( ( ! empty( $max_payments ) && $max_payments > 0 ) || ( 'split_payment' === $payment_type && $max_payments > 0 ) ) :
118 $payments_made = subscrpt_count_payments_made( $post->ID );
119 ?>
120 <tr>
121 <th style="padding:8px 10px;"><?php esc_html_e( 'Total Payments', 'subscription' ); ?></th>
122 <td style="padding:8px 10px;"><?php echo esc_html( $payments_made ) . ' / ' . esc_html( $max_payments ); ?></td>
123 </tr>
124 <?php endif; ?>
125
126 <?php
127 // Display Payment Type and Access Duration information
128 $payment_type = $product_id ? get_post_meta( $product_id, '_subscrpt_payment_type', true ) : 'recurring';
129 $payment_type = $payment_type ?: 'recurring'; // Default to recurring if empty
130
131 // Also check subscription's own meta data
132 $subscription_payment_type = get_post_meta( $post->ID, '_subscrpt_payment_type', true );
133 $subscription_max_payments = get_post_meta( $post->ID, '_subscrpt_max_no_payment', true );
134
135 // Also check if this subscription has variation data
136 $variation_id = get_post_meta( $post->ID, '_subscrpt_variation_id', true );
137 if ( $variation_id ) {
138 $variation_payment_type = get_post_meta( $variation_id, '_subscrpt_payment_type', true );
139 $variation_max_payments = get_post_meta( $variation_id, '_subscrpt_max_no_payment', true );
140
141 // Use variation data if product data is not available
142 if ( empty( $payment_type ) || 'recurring' === $payment_type ) {
143 if ( ! empty( $variation_payment_type ) ) {
144 $payment_type = $variation_payment_type;
145 }
146 }
147 if ( ! $max_payments && ! empty( $variation_max_payments ) ) {
148 $max_payments = $variation_max_payments;
149 }
150 }
151
152 // Use subscription's own data if available and more specific
153 if ( ! empty( $subscription_payment_type ) ) {
154 $payment_type = $subscription_payment_type;
155 }
156 if ( ! empty( $subscription_max_payments ) ) {
157 $max_payments = $subscription_max_payments;
158 }
159
160 // Final fallback: Infer payment type from max_payments if not explicitly set
161 if ( ( empty( $payment_type ) || 'recurring' === $payment_type ) && $max_payments > 0 ) {
162 $payment_type = 'split_payment';
163 }
164
165 // Ensure max_payments is properly set for display
166 $max_payments = (int) $max_payments;
167 ?>
168 <tr>
169 <th style="padding:8px 10px;"><?php esc_html_e( 'Payment Type', 'subscription' ); ?></th>
170 <td style="padding:8px 10px;">
171 <?php
172 if ( 'split_payment' === $payment_type ) {
173 esc_html_e( 'Split Payment', 'subscription' );
174 } else {
175 esc_html_e( 'Recurring', 'subscription' );
176 }
177 ?>
178 </td>
179 </tr>
180
181 <!-- Access Duration Information for Split Payments -->
182 <?php if ( 'split_payment' === $payment_type && ! empty( $max_payments ) && $max_payments > 0 ) : ?>
183 <?php
184 $access_ends_timing = get_post_meta( $product_id, '_subscrpt_access_ends_timing', true ) ?: 'after_full_duration';
185 $custom_duration_time = get_post_meta( $product_id, '_subscrpt_custom_access_duration_time', true ) ?: 1;
186 $custom_duration_type = get_post_meta( $product_id, '_subscrpt_custom_access_duration_type', true ) ?: 'months';
187
188 // Calculate access end date if Pro version is available
189 $access_end_date_string = null;
190 if ( function_exists( 'subscrpt_pro_activated' ) && subscrpt_pro_activated() ) {
191 if ( class_exists( '\SpringDevs\SubscriptionPro\Illuminate\SplitPaymentHandler' ) ) {
192 $access_end_date_string = \SpringDevs\SubscriptionPro\Illuminate\SplitPaymentHandler::get_access_end_date_string( $post->ID );
193 }
194 }
195 ?>
196 <tr>
197 <th style="padding:8px 10px;"><?php esc_html_e( 'Access Duration', 'subscription' ); ?></th>
198 <td style="padding:8px 10px;">
199 <?php
200 switch ( $access_ends_timing ) {
201 case 'lifetime':
202 esc_html_e( 'Lifetime access after completion', 'subscription' );
203 break;
204 case 'after_full_duration':
205 esc_html_e( 'Full subscription duration', 'subscription' );
206 break;
207 case 'custom_duration':
208 printf(
209 /* translators: %1$s: duration time, %2$s: duration type */
210 esc_html__( '%1$s %2$s after first payment', 'subscription' ),
211 esc_html( $custom_duration_time ),
212 esc_html( ucfirst( SpringDevs\Subscription\Illuminate\Helper::get_typos( $custom_duration_time, $custom_duration_type, true ) ) )
213 );
214 break;
215 default:
216 esc_html_e( 'Full subscription duration', 'subscription' );
217 break;
218 }
219 ?>
220 </td>
221 </tr>
222
223 <!-- Show calculated access end date if available -->
224 <?php if ( $access_end_date_string ) : ?>
225 <tr>
226 <th style="padding:8px 10px;"><?php esc_html_e( 'Access Ends On', 'subscription' ); ?></th>
227 <td style="padding:8px 10px;"><?php echo esc_html( $access_end_date_string ); ?></td>
228 </tr>
229 <?php endif; ?>
230 <?php endif; ?>
231
232 <tr>
233 <th style="padding:8px 10px;">Started date</th>
234 <td style="padding:8px 10px;"><?php echo $start_date ? esc_html( wp_date( 'F d, Y', $start_date ) ) : '-'; ?></td>
235 </tr>
236 <tr>
237 <th style="padding:8px 10px;">Payment due date</th>
238 <td style="padding:8px 10px;"><?php echo $renewal_date ? esc_html( wp_date( 'F d, Y', $renewal_date ) ) : '-'; ?></td>
239 </tr>
240 <tr>
241 <th style="padding:8px 10px;">Status</th>
242 <td style="padding:8px 10px;"><span class="subscrpt-<?php echo esc_attr( $status_obj->name ); ?>"><?php echo esc_html( $status_obj->label ); ?></span></td>
243 </tr>
244 <tr>
245 <th style="padding:8px 10px;">Payment Method</th>
246 <td style="padding:8px 10px;"><?php echo esc_html( $payment_method ); ?></td>
247 </tr>
248 </tbody>
249 </table>
250 </div>
251 <!-- Right: Billing & Shipping -->
252 <div class="wp-subscription-admin-box wp-subscription-info-right" style="box-shadow: 0 1px 3px rgb(29 35 39 / 30%);background:#fff;flex:1 1 50%;max-width:50%;margin:25px 0 18px 0;">
253 <table class="widefat wp-subscription-list-table" style="border-radius:8px;overflow:hidden;margin-bottom:0;background:none;">
254 <tbody>
255 <tr>
256 <th style="width:70px;padding:8px 10px;">Billing</th>
257 <td style="padding:8px 10px;"><?php echo $billing_address ? wp_kses_post( $billing_address ) : '-'; ?></td>
258 </tr>
259 <tr>
260 <th style="width:70px;padding:8px 10px;">Shipping</th>
261 <td style="padding:8px 10px;"><?php echo $shipping_address ? wp_kses_post( $shipping_address ) : '-'; ?></td>
262 </tr>
263 </tbody>
264 </table>
265 </div>
266 </div>
267 </div>
268 <style>
269 @media (max-width: 900px) {
270 .wp-subscription-info-left, .wp-subscription-info-right {
271 flex-basis: 100% !important;
272 max-width: 100% !important;
273 margin-left: 0 !important;
274 margin-right: 0 !important;
275 }
276 .wp-subscription-info-grid {
277 flex-direction: column !important;
278 gap: 18px !important;
279 }
280 }
281 </style>
282