PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.10.2
Subscriptions for WooCommerce with Stripe Recurring Payments v1.10.2
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 / subscriptions.php

subscriptions.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.10.2, at templates/myaccount/subscriptions.php

160 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Subscriptions Table
4 *
5 * @var int $current_page
6 * @var WP_Query $postslist
7 *
8 * This template can be overridden by copying it to <your_theme>/subscription/myaccount/subscriptions.php
9 */
10
11 // Exit if accessed directly.
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15 ?>
16
17 <table class="woocommerce-orders-table woocommerce-MyAccount-orders shop_table shop_table_responsive my_account_orders account-orders-table my_account_subscrpt">
18 <thead>
19 <tr>
20 <th scope="col" class="subscrpt-id"><?php esc_html_e( 'Subscription', 'subscription' ); ?></th>
21 <th scope="col" class="order-status"><?php esc_html_e( 'Status', 'subscription' ); ?></th>
22 <th scope="col" class="order-product"><?php esc_html_e( 'Product', 'subscription' ); ?></th>
23 <th scope="col" class="subscrpt-next-date"><?php esc_html_e( 'Next Payment', 'subscription' ); ?></th>
24 <th scope="col" class="subscrpt-total"><?php esc_html_e( 'Total', 'subscription' ); ?></th>
25 <th scope="col" class="subscrpt-action">Actions</th>
26 </tr>
27 </thead>
28 <tbody>
29 <?php
30 if ( $postslist->have_posts() ) :
31 while ( $postslist->have_posts() ) :
32 $postslist->the_post();
33
34 $subscription_id = get_the_ID();
35 $subscription_data = SpringDevs\Subscription\Illuminate\Helper::get_subscription_data( $subscription_id );
36
37 if ( ! $subscription_data ) {
38 continue;
39 }
40
41 $subscrpt_status = $subscription_data['status'] ?? '';
42 $verbose_status = SpringDevs\Subscription\Illuminate\Helper::get_verbose_status( $subscrpt_status );
43
44 $order_id = $subscription_data['order']['order_id'] ?? 0;
45 $order_item_id = $subscription_data['order']['order_item_id'] ?? 0;
46
47 $order = wc_get_order( $order_id );
48 $order_item = $order ? $order->get_item( $order_item_id ) : null;
49
50 if ( ! $order || ! $order_item ) {
51 subscrpt_write_log( sprintf( 'Order or order item not found for subscription #%d', $subscription_id ) );
52 continue;
53 }
54
55 $product_id = $subscription_data['product']['product_id'] ?? 0;
56 $product_name = $order_item->get_name();
57
58 $start_date = $subscription_data['start_date'] ?? '';
59 $start_date = ! empty( $start_date ) ? wp_date( 'F j, Y', strtotime( $start_date ) ) : '-';
60
61 $next_date = $subscription_data['next_date'] ?? '';
62 $next_date = ! empty( $next_date ) ? wp_date( 'F j, Y', strtotime( $next_date ) ) : '-';
63
64 $trial = get_post_meta( get_the_ID(), '_subscrpt_trial', true );
65 $trial_mode = get_post_meta( get_the_ID(), '_subscrpt_trial_mode', true );
66 $trial_mode = empty( $trial_mode ) ? 'off' : $trial_mode;
67
68 $quantity = (int) $order_item->get_quantity();
69 $price = (float) ( $subscription_data['price'] ?? 0 ) * max( 1, $quantity );
70 $price_excl_tax = (float) $order_item->get_total();
71 $tax_amount = (float) $order_item->get_total_tax();
72
73 if ( $tax_amount > 0 ) {
74 $price = $price_excl_tax + $tax_amount;
75 $price = number_format( (float) $price, 2, '.', '' );
76 }
77
78 $product_price_html = SpringDevs\Subscription\Illuminate\Helper::format_price_with_order_item( $price, $order_item->get_id() );
79
80 $is_grace_period = isset( $subscription_data['grace_period'] );
81 $grace_remaining = $subscription_data['grace_period']['remaining_days'] ?? 0;
82
83 $my_account_page_id = get_option( 'woocommerce_myaccount_page_id' );
84 $my_account_url = get_permalink( $my_account_page_id );
85 $view_sub_endpoint = SpringDevs\Subscription\Illuminate\Subscription\Subscription::get_user_endpoint( 'view_subs' );
86 $view_sub_url = wc_get_endpoint_url( $view_sub_endpoint, get_the_ID(), $my_account_url );
87 ?>
88
89 <tr>
90 <td data-title="Subscription"><?php the_ID(); ?></td>
91
92 <td data-title="Status">
93 <?php if ( $is_grace_period && $grace_remaining > 0 ) : ?>
94 <span class="subscrpt-active grace-active">
95 Active
96
97 <?php
98 $grace_remaining_text = sprintf(
99 // translators: Number of days remaining in grace period.
100 __( '%d days remaining!', 'subscription' ),
101 $grace_remaining
102 );
103 ?>
104 <span class="grace-icon" data-tooltip="<?php echo esc_attr( $grace_remaining_text ); ?>">
105 <span class="dashicons dashicons-warning"></span>
106 </span>
107 </span>
108 <?php else : ?>
109 <span class="subscrpt-<?php echo esc_attr( strtolower( $subscrpt_status ) ); ?>">
110 <?php echo esc_html( strlen( $verbose_status ) > 9 ? substr( $verbose_status, 0, 9 ) . '...' : $verbose_status ); ?>
111 </span>
112 <?php endif; ?>
113 </td>
114
115 <td data-title="Product"><?php echo esc_html( $product_name ); ?></td>
116
117 <?php if ( 'on' !== $trial_mode ) : ?>
118 <td data-title="Next Payment"><?php echo esc_html( $next_date ); ?></td>
119 <?php else : ?>
120 <td data-title="Next Payment"><small>First Billing : </small><?php echo esc_html( $start_date ); ?></td>
121 <?php endif; ?>
122
123 <td data-title="Total"><?php echo wp_kses_post( $product_price_html ); ?></td>
124
125 <td data-title="Actions">
126 <a href="<?php echo esc_url( $view_sub_url ); ?>" class="woocommerce-button <?php echo esc_attr( $wp_button_class ); ?> button view">
127 <?php echo esc_html_e( 'View', 'subscription' ); ?>
128 </a>
129 </td>
130 </tr>
131 <?php
132 endwhile;
133 wp_reset_postdata();
134 else :
135 ?>
136 <tr>
137 <td colspan="6">
138 <p style="text-align: center;">
139 <?php echo esc_html_e( 'No subscriptions available yet.', 'subscription' ); ?>
140 </p>
141 </td>
142 </tr>
143 <?php
144 endif;
145 ?>
146 </tbody>
147 </table>
148
149 <?php if ( 1 < $postslist->max_num_pages ) : ?>
150 <div class="woocommerce-pagination woocommerce-pagination--without-numbers woocommerce-Pagination">
151 <?php if ( 1 !== $current_page ) : ?>
152 <a class="woocommerce-button woocommerce-button--previous woocommerce-Button woocommerce-Button--previous button<?php echo esc_attr( $wp_button_class ); ?>" href="<?php echo esc_url( wc_get_endpoint_url( 'subscriptions', $current_page - 1 ) ); ?>"><?php esc_html_e( 'Previous', 'subscription' ); ?></a>
153 <?php endif; ?>
154
155 <?php if ( intval( $postslist->max_num_pages ) !== $current_page ) : ?>
156 <a class="woocommerce-button woocommerce-button--next woocommerce-Button woocommerce-Button--next button<?php echo esc_attr( $wp_button_class ); ?>" href="<?php echo esc_url( wc_get_endpoint_url( 'subscriptions', $current_page + 1 ) ); ?>"><?php esc_html_e( 'Next', 'subscription' ); ?></a>
157 <?php endif; ?>
158 </div>
159 <?php endif; ?>
160