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