PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.10.1
Subscriptions for WooCommerce with Stripe Recurring Payments v1.10.1
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 / templates / myaccount / single.php

single.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.10.1, at templates/myaccount/single.php

421 lines 14.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly.
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6 /**
7 * Single subscription page
8 *
9 * @var WC_Order $order
10 * @var WC_Order_Item $order_item
11 * @var array $related_orders
12 * @var string $start_date
13 * @var string $next_date
14 * @var string|null $trial
15 * @var string|null $trial_mode
16 * @var string $status
17 * @var array $action_buttons
18 * @var bool $is_grace_period
19 * @var int $grace_remaining
20 *
21 * This template can be overridden by copying it to <your_theme>/subscription/myaccount/single.php
22 *
23 * @package SpringDevs\Subscription
24 */
25
26 use SpringDevs\Subscription\Illuminate\Helper;
27
28 if ( ! isset( $id ) ) {
29 return;
30 }
31
32 if ( ! get_the_title( $id ) ) {
33 return;
34 }
35
36 do_action( 'before_single_subscrpt_content', $id );
37 ?>
38 <style>
39 .auto-renew-on,
40 .subscription_renewal_early,
41 .auto-renew-off {
42 margin-bottom: 10px;
43 }
44 .subscrpt_action_buttons {
45 display: flex;
46 flex-wrap: wrap;
47 gap: 10px;
48 }
49 </style>
50 <table class="woocommerce-table woocommerce-table--order-details shop_table order_details subscription_details">
51 <tbody>
52 <tr>
53 <td><?php esc_html_e( 'Order', 'subscription' ); ?></td>
54 <td><a href="<?php echo esc_html( wc_get_endpoint_url( 'view-order', $order->get_id(), wc_get_page_permalink( 'myaccount' ) ) ); ?>" target="_blank"># <?php echo esc_html( $order->get_id() ); ?></a></td>
55 </tr>
56 <tr>
57 <td><?php esc_html_e( 'Status', 'subscription' ); ?></td>
58 <td>
59 <?php if ( $is_grace_period && $grace_remaining > 0 ) : ?>
60 <span class="subscrpt-active grace-active">
61 Active
62
63 <?php
64 $grace_remaining_text = sprintf(
65 // translators: Number of days remaining in grace period.
66 __( '%d days remaining!', 'subscription' ),
67 $grace_remaining
68 );
69 ?>
70 <span class="grace-icon" data-tooltip="<?php echo esc_attr( $grace_remaining_text ); ?>">
71 <span class="dashicons dashicons-warning"></span>
72 </span>
73 </span>
74 <?php else : ?>
75 <span class="subscrpt-<?php echo esc_attr( strtolower( $status ) ); ?>">
76 <?php echo esc_html( $verbose_status ); ?>
77 </span>
78 <?php endif; ?>
79 </td>
80 </tr>
81
82 <?php if ( $is_grace_period && $grace_remaining > 0 ) : ?>
83 <tr>
84 <td><?php esc_html_e( 'Grace Period Ends On', 'subscription' ); ?></td>
85 <td><?php echo esc_html( $grace_end_date ); ?></td>
86 </tr>
87 <?php endif; ?>
88
89 <?php if ( null != $trial && 'off' !== $trial ) : ?>
90 <tr>
91 <td><?php esc_html_e( 'Trial', 'subscription' ); ?></td>
92 <td><?php echo esc_html( $trial ); ?></td>
93 </tr>
94 <?php endif; ?>
95 <tr>
96 <td>
97 <?php
98 if ( 'null' == $trial || 'off' === $trial_mode ) {
99 esc_html_e( 'Start date', 'subscription' );
100 } elseif ( 'extended' === $trial_mode ) {
101 esc_html_e( 'Trial End & Subscription Start', 'subscription' );
102 } else {
103 esc_html_e( 'Trial End & First Billing', 'subscription' );
104 }
105 ?>
106 </td>
107 <td><?php echo esc_html( $start_date ); ?></td>
108 </tr>
109 <?php if ( null == $trial || in_array( $trial_mode, array( 'off', 'extended' ), true ) ) : ?>
110 <tr>
111 <td>
112 <?php
113 esc_html_e( 'Next payment date', 'subscription' );
114 ?>
115 </td>
116 <td>
117 <?php echo esc_html( $next_date ); ?>
118 </td>
119 </tr>
120 <?php endif; ?>
121
122 <!-- get the max_no_payment info using Helper -->
123 <?php $remaining_payments = subscrpt_get_remaining_payments( $id ); ?>
124 <?php $payments_made = subscrpt_count_payments_made( $id ); ?>
125 <?php
126 // Get maximum payments using helper function (handles variations properly)
127 $product_id = get_post_meta( $id, '_subscrpt_product_id', true );
128 $max_payments = subscrpt_get_max_payments( $id );
129
130 // Get Payment Type and Access Duration Information
131 $payment_type = $product_id ? get_post_meta( $product_id, '_subscrpt_payment_type', true ) : 'recurring';
132 $payment_type = $payment_type ?: 'recurring'; // Default to recurring if empty
133
134 // Also check subscription's own meta data
135 $subscription_payment_type = get_post_meta( $id, '_subscrpt_payment_type', true );
136 $subscription_max_payments = get_post_meta( $id, '_subscrpt_max_no_payment', true );
137
138 // Also check if this subscription has variation data
139 $variation_id = get_post_meta( $id, '_subscrpt_variation_id', true );
140 if ( $variation_id ) {
141 $variation_payment_type = get_post_meta( $variation_id, '_subscrpt_payment_type', true );
142 $variation_max_payments = get_post_meta( $variation_id, '_subscrpt_max_no_payment', true );
143
144 // Use variation data if product data is not available
145 if ( empty( $payment_type ) || 'recurring' === $payment_type ) {
146 if ( ! empty( $variation_payment_type ) ) {
147 $payment_type = $variation_payment_type;
148 }
149 }
150 if ( empty( $max_payments ) && ! empty( $variation_max_payments ) ) {
151 $max_payments = $variation_max_payments;
152 }
153 }
154
155 // Use subscription's own data if available and more specific
156 if ( ! empty( $subscription_payment_type ) ) {
157 $payment_type = $subscription_payment_type;
158 }
159 if ( ! empty( $subscription_max_payments ) ) {
160 $max_payments = $subscription_max_payments;
161 }
162
163 // Final fallback: Infer payment type from max_payments if not explicitly set
164 if ( ( empty( $payment_type ) || 'recurring' === $payment_type ) && $max_payments > 0 ) {
165 $payment_type = 'split_payment';
166 }
167
168 // Ensure max_payments is properly set for display
169 $max_payments = (int) $max_payments;
170 ?>
171
172 <!-- show payment progress if max_payments is set and not unlimited -->
173 <?php if ( ( $remaining_payments !== 'unlimited' && $max_payments > 0 ) || ( 'split_payment' === $payment_type && $max_payments > 0 ) ) : ?>
174 <tr>
175 <td><?php esc_html_e( 'Total Payments', 'subscription' ); ?></td>
176 <td><?php echo esc_html( $payments_made ) . ' / ' . esc_html( $max_payments ); ?></td>
177 </tr>
178 <?php endif; ?>
179
180 <tr>
181 <td><?php esc_html_e( 'Payment Type', 'subscription' ); ?></td>
182 <td>
183 <?php
184 if ( 'split_payment' === $payment_type ) {
185 esc_html_e( 'Split Payment', 'subscription' );
186 } else {
187 esc_html_e( 'Recurring', 'subscription' );
188 }
189 ?>
190 <!-- DEBUG: Show raw values -->
191 <!-- <small style="color: #666; font-size: 11px; display: block;">
192 Debug: Product ID: <?php echo esc_html( $product_id ); ?>,
193 Variation ID: <?php echo esc_html( $variation_id ?: 'None' ); ?>,
194 Type: <?php echo esc_html( $payment_type ); ?>,
195 Max: <?php echo esc_html( $max_payments ); ?>
196 </small> -->
197 </td>
198 </tr>
199
200 <!-- Access Duration Information for Split Payments -->
201 <?php if ( 'split_payment' === $payment_type && $max_payments > 0 ) : ?>
202 <?php
203 $access_ends_timing = get_post_meta( $product_id, '_subscrpt_access_ends_timing', true ) ?: 'after_full_duration';
204 $custom_duration_time = get_post_meta( $product_id, '_subscrpt_custom_access_duration_time', true ) ?: 1;
205 $custom_duration_type = get_post_meta( $product_id, '_subscrpt_custom_access_duration_type', true ) ?: 'months';
206
207 // Calculate access end date if Pro version is available
208 $access_end_date_string = null;
209 if ( function_exists( 'subscrpt_pro_activated' ) && subscrpt_pro_activated() ) {
210 if ( class_exists( '\SpringDevs\SubscriptionPro\Illuminate\SplitPaymentHandler' ) ) {
211 $access_end_date_string = \SpringDevs\SubscriptionPro\Illuminate\SplitPaymentHandler::get_access_end_date_string( $id );
212 }
213 }
214 ?>
215 <tr>
216 <td><?php esc_html_e( 'Access Duration', 'subscription' ); ?></td>
217 <td>
218 <?php
219 switch ( $access_ends_timing ) {
220 case 'lifetime':
221 esc_html_e( 'Lifetime access after completion', 'subscription' );
222 break;
223 case 'after_full_duration':
224 esc_html_e( 'Full subscription duration', 'subscription' );
225 break;
226 case 'custom_duration':
227 printf(
228 /* translators: %1$s: duration time, %2$s: duration type */
229 esc_html__( '%1$s %2$s after first payment', 'subscription' ),
230 esc_html( $custom_duration_time ),
231 esc_html( ucfirst( Helper::get_typos( $custom_duration_time, $custom_duration_type, true ) ) )
232 );
233 break;
234 default:
235 esc_html_e( 'Full subscription duration', 'subscription' );
236 break;
237 }
238 ?>
239 </td>
240 </tr>
241
242 <!-- Show calculated access end date if available -->
243 <?php if ( $access_end_date_string ) : ?>
244 <tr>
245 <td><?php esc_html_e( 'Access Ends On', 'subscription' ); ?></td>
246 <td><?php echo esc_html( $access_end_date_string ); ?></td>
247 </tr>
248 <?php endif; ?>
249 <?php endif; ?>
250
251 <?php if ( ! empty( $order->get_payment_method_title() ) ) : ?>
252 <tr>
253 <td><?php esc_html_e( 'Payment', 'subscription' ); ?></td>
254 <td>
255 <span data-is_manual="yes" class="subscription-payment-method"><?php echo esc_html( $order->get_payment_method_title() ); ?></span>
256 </td>
257 </tr>
258 <?php endif; ?>
259 <?php if ( 0 < count( $action_buttons ) ) : ?>
260 <tr>
261 <td><?php echo esc_html_e( 'Actions', 'subscription' ); ?></td>
262 <td class="subscrpt_action_buttons">
263 <?php foreach ( $action_buttons as $action_button ) : ?>
264 <a href="<?php echo esc_attr( $action_button['url'] ); ?>" class="button
265 <?php
266 if ( isset( $action_button['class'] ) ) {
267 echo esc_attr( $action_button['class'] );}
268 ?>
269 <?php echo esc_attr( $wp_button_class ); ?>"><?php echo esc_html( $action_button['label'] ); ?></a>
270 <?php endforeach; ?>
271 </td>
272 </tr>
273 <?php endif; ?>
274 </tbody>
275 </table>
276
277 <?php do_action( 'subscrpt_before_subscription_totals', (int) $id ); ?>
278
279 <h2><?php echo esc_html_e( 'Subscription Totals', 'subscription' ); ?></h2>
280 <table class="woocommerce-table woocommerce-table--order-details shop_table order_details">
281 <thead>
282 <tr>
283 <th class="product-name"><?php echo esc_html_e( 'Product', 'subscription' ); ?></th>
284 <th class="product-total"><?php echo esc_html_e( 'Total', 'subscription' ); ?></th>
285 </tr>
286 </thead>
287 <tbody>
288 <?php
289 $product_name = $order_item->get_name();
290 $product_link = get_permalink( $order_item->get_variation_id() !== 0 ? $order_item->get_variation_id() : $order_item->get_product_id() );
291 $order_item_meta = $order_item->get_meta( '_subscrpt_meta', true );
292 $time = '1' === $order_item_meta['time'] ? null : $order_item_meta['time'];
293 $type = subscrpt_get_typos( $order_item_meta['time'], $order_item_meta['type'] );
294 $product_price_html = Helper::format_price_with_order_item( $price, $order_item->get_id() );
295 ?>
296 <tr class="order_item">
297 <td class="product-name">
298 <a href="<?php echo esc_html( $product_link ); ?>"><?php echo esc_html( $product_name ); ?></a>
299 <strong class="product-quantity">× <?php echo esc_html( $order_item->get_quantity() ); ?></strong>
300 </td>
301 <td class="product-total">
302 <span class="woocommerce-Price-amount amount">
303 <?php
304 $unit_price = (float) get_post_meta( $id, '_subscrpt_price', true );
305 $display_price = $unit_price * max( 1, (int) $order_item->get_quantity() );
306 echo wp_kses_post( Helper::format_price_with_order_item( $display_price, $order_item->get_id() ) );
307 ?>
308 </span>
309 </td>
310 </tr>
311 </tbody>
312 <tfoot>
313 <tr>
314 <th scope="row"><?php esc_html_e( 'Subtotal', 'subscription' ); ?>:</th>
315 <td>
316 <span class="woocommerce-Price-amount amount">
317 <?php echo wp_kses_post( wc_price( $price_excl_tax, array( 'currency' => $order->get_currency() ) ) ); ?>
318 </span>
319 </td>
320 </tr>
321
322 <?php if ( $tax > 0 ) : ?>
323 <tr>
324 <th scope="row"><?php esc_html_e( 'Tax', 'subscription' ); ?>:</th>
325 <td>
326 <span class="woocommerce-Price-amount amount">
327 <?php echo wp_kses_post( wc_price( $tax, array( 'currency' => $order->get_currency() ) ) ); ?>
328 </span>
329 </td>
330 </tr>
331 <?php endif; ?>
332
333 <tr>
334 <th scope="row"><?php esc_html_e( 'Renew', 'subscription' ); ?>:</th>
335 <td>
336 <span class="woocommerce-Price-amount amount">
337 <?php echo wp_kses_post( $product_price_html ); ?>
338 </span>
339 </td>
340 </tr>
341 </tfoot>
342 </table>
343
344 <?php do_action( 'subscrpt_after_subscription_totals', (int) $id ); ?>
345
346 <!-- Show related subscription orders -->
347 <h2><?php echo esc_html_e( 'Related Orders', 'subscription' ); ?></h2>
348 <table class="woocommerce-table woocommerce-table--order-details shop_table order_details">
349 <thead>
350 <tr>
351 <th class="order-number"><?php echo esc_html_e( 'Order', 'subscription' ); ?></th>
352 <th class="order-type"><?php echo esc_html_e( 'Type', 'subscription' ); ?></th>
353 <th class="order-date"><?php echo esc_html_e( 'Date', 'subscription' ); ?></th>
354 <th class="order-status"><?php echo esc_html_e( 'Status', 'subscription' ); ?></th>
355 <th class="order-total"><?php echo esc_html_e( 'Total', 'subscription' ); ?></th>
356 </tr>
357 </thead>
358 <tbody>
359 <?php if ( empty( $related_orders ) ) : ?>
360 <tr class="order_item">
361 <td colspan="5" class="no-orders">
362 <?php echo esc_html_e( 'No related orders found.', 'subscription' ); ?>
363 </td>
364 </tr>
365 <?php endif; ?>
366
367 <?php foreach ( $related_orders as $related_order ) : ?>
368 <?php
369 $order_id = $related_order->order_id;
370 $order = wc_get_order( $order_id );
371 if ( ! $order ) {
372 continue;
373 }
374
375 $order_type = $related_order->type;
376 $order_type_label = wps_subscription_order_relation_type_cast( $order_type );
377
378 $order_created_date = $order->get_date_created()->date_i18n( get_option( 'date_format' ) );
379
380 $order_status = $order->get_status();
381 $order_status_name = wc_get_order_status_name( $order_status );
382
383 $order_total = $order->get_total();
384 $formatted_order_total = wc_price( $order_total, array( 'currency' => $order->get_currency() ) );
385 ?>
386
387 <tr class="order_item">
388 <td class="order-number">
389 <a href="<?php echo esc_url( wc_get_endpoint_url( 'view-order', $order_id, wc_get_page_permalink( 'myaccount' ) ) ); ?>">
390 #<?php echo esc_html( $order_id ); ?>
391 </a>
392 </td>
393 <td class="order-type">
394 <?php echo esc_html( $order_type_label ); ?>
395 </td>
396 <td class="order-date">
397 <?php echo esc_html( $order_created_date ); ?>
398 </td>
399 <td class="order-status">
400 <span class="order-status-<?php echo esc_attr( $order_status ); ?>">
401 <?php echo esc_html( $order_status_name ); ?>
402 </span>
403 </td>
404 <td class="order-total">
405 <?php echo wp_kses_post( $formatted_order_total ); ?>
406 </td>
407 </tr>
408 <?php endforeach; ?>
409 </tbody>
410 </table>
411
412 <section class="woocommerce-customer-details">
413 <h2 class="woocommerce-column__title"><?php esc_html_e( 'Billing address', 'subscription' ); ?></h2>
414 <address>
415 <?php echo wp_kses_post( $order->get_formatted_billing_address() ); ?>
416 <p class="woocommerce-customer-details--phone"><?php echo esc_html( $order->get_billing_phone() ); ?></p>
417 <p class="woocommerce-customer-details--email"><?php echo esc_html( $order->get_billing_email() ); ?></p>
418 </address>
419 </section>
420 <div class="clear"></div>
421