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 +26 -29 1.10.0 → 2.4.0 View file →
@@ -7,8 +7,11 @@
7 7 *
8 8 * This template can be overridden by copying it to <your_theme>/subscription/myaccount/subscriptions.php
9 9 */
10 10
11 +use SpringDevs\Subscription\Illuminate\Helper;
12 +use SpringDevs\Subscription\Illuminate\Subscription\Subscription;
13 +
11 14 // Exit if accessed directly.
12 15 if ( ! defined( 'ABSPATH' ) ) {
13 16 exit;
14 17 }
@@ -21,9 +24,9 @@
21 24 <th scope="col" class="order-status"><?php esc_html_e( 'Status', 'subscription' ); ?></th>
22 25 <th scope="col" class="order-product"><?php esc_html_e( 'Product', 'subscription' ); ?></th>
23 26 <th scope="col" class="subscrpt-next-date"><?php esc_html_e( 'Next Payment', 'subscription' ); ?></th>
24 27 <th scope="col" class="subscrpt-total"><?php esc_html_e( 'Total', 'subscription' ); ?></th>
25 - <th scope="col" class="subscrpt-action">Actions</th>
28 + <th scope="col" class="subscrpt-action"><?php esc_html_e( 'Actions', 'subscription' ); ?></th>
26 29 </tr>
27 30 </thead>
28 31 <tbody>
29 32 <?php
@@ -31,9 +34,9 @@
31 34 while ( $postslist->have_posts() ) :
32 35 $postslist->the_post();
33 36
34 37 $subscription_id = get_the_ID();
35 - $subscription_data = SpringDevs\Subscription\Illuminate\Helper::get_subscription_data( $subscription_id );
38 + $subscription_data = Helper::get_subscription_data( $subscription_id );
36 39
37 40 if ( ! $subscription_data ) {
38 41 continue;
39 42 }
@@ -38,9 +41,9 @@
38 41 continue;
39 42 }
40 43
41 44 $subscrpt_status = $subscription_data['status'] ?? '';
42 - $verbose_status = SpringDevs\Subscription\Illuminate\Helper::get_verbose_status( $subscrpt_status );
45 + $verbose_status = Helper::get_verbose_status( $subscrpt_status );
43 46
44 47 $order_id = $subscription_data['order']['order_id'] ?? 0;
45 48 $order_item_id = $subscription_data['order']['order_item_id'] ?? 0;
46 49
@@ -58,42 +61,36 @@
58 61 $start_date = $subscription_data['start_date'] ?? '';
59 62 $start_date = ! empty( $start_date ) ? wp_date( 'F j, Y', strtotime( $start_date ) ) : '-';
60 63
61 64 $next_date = $subscription_data['next_date'] ?? '';
62 - $next_date = ! empty( $next_date ) ? wp_date( 'F j, Y', strtotime( $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 ) ) : '-';
63 66
64 67 $trial = get_post_meta( get_the_ID(), '_subscrpt_trial', true );
65 68 $trial_mode = get_post_meta( get_the_ID(), '_subscrpt_trial_mode', true );
66 69 $trial_mode = empty( $trial_mode ) ? 'off' : $trial_mode;
67 70
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();
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'];
72 74
73 - if ( $tax_amount > 0 ) {
74 - $price = $price_excl_tax + $tax_amount;
75 - $price = number_format( (float) $price, 2, '.', '' );
76 - }
75 + $product_price_html = Helper::format_price_with_order_item( $price, $order_item->get_id() );
77 76
78 - $product_price_html = SpringDevs\Subscription\Illuminate\Helper::format_price_with_order_item( $price, $order_item->get_id() );
79 -
80 77 $is_grace_period = isset( $subscription_data['grace_period'] );
81 78 $grace_remaining = $subscription_data['grace_period']['remaining_days'] ?? 0;
82 79
83 80 $my_account_page_id = get_option( 'woocommerce_myaccount_page_id' );
84 81 $my_account_url = get_permalink( $my_account_page_id );
85 - $view_sub_endpoint = SpringDevs\Subscription\Illuminate\Subscription\Subscription::get_user_endpoint( 'view_subs' );
82 + $view_sub_endpoint = Subscription::get_user_endpoint( 'view_subs' );
86 83 $view_sub_url = wc_get_endpoint_url( $view_sub_endpoint, get_the_ID(), $my_account_url );
87 84 ?>
88 85
89 86 <tr>
90 - <td data-title="Subscription"><?php the_ID(); ?></td>
87 + <td data-title="<?php echo esc_attr__( 'Subscription', 'subscription' ); ?>"><?php the_ID(); ?></td>
91 88
92 - <td data-title="Status">
89 + <td data-title="<?php echo esc_attr__( 'Status', 'subscription' ); ?>">
93 90 <?php if ( $is_grace_period && $grace_remaining > 0 ) : ?>
94 - <span class="subscrpt-active grace-active">
95 - Active
91 + <span class="subscrpt-legacy-status subscrpt-legacy-status--active grace-active">
92 + <?php esc_html_e( 'Active', 'subscription' ); ?>
96 93
97 94 <?php
98 95 $grace_remaining_text = sprintf(
99 96 // translators: Number of days remaining in grace period.
@@ -105,25 +102,25 @@
105 102 <span class="dashicons dashicons-warning"></span>
106 103 </span>
107 104 </span>
108 105 <?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 ); ?>
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 ); ?>
111 108 </span>
112 109 <?php endif; ?>
113 110 </td>
114 111
115 - <td data-title="Product"><?php echo esc_html( $product_name ); ?></td>
112 + <td data-title="<?php echo esc_attr__( 'Product', 'subscription' ); ?>"><?php echo esc_html( $product_name ); ?></td>
116 113
117 - <?php if ( 'on' !== $trial_mode ) : ?>
118 - <td data-title="Next Payment"><?php echo esc_html( $next_date ); ?></td>
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>
119 116 <?php else : ?>
120 - <td data-title="Next Payment"><small>First Billing : </small><?php echo esc_html( $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>
121 118 <?php endif; ?>
122 119
123 - <td data-title="Total"><?php echo wp_kses_post( $product_price_html ); ?></td>
120 + <td data-title="<?php echo esc_attr__( 'Total', 'subscription' ); ?>"><?php echo wp_kses_post( $product_price_html ); ?></td>
124 121
125 - <td data-title="Actions">
122 + <td data-title="<?php echo esc_attr__( 'Actions', 'subscription' ); ?>">
126 123 <a href="<?php echo esc_url( $view_sub_url ); ?>" class="woocommerce-button <?php echo esc_attr( $wp_button_class ); ?> button view">
127 124 <?php echo esc_html_e( 'View', 'subscription' ); ?>
128 125 </a>
129 126 </td>
@@ -148,12 +145,12 @@
148 145
149 146 <?php if ( 1 < $postslist->max_num_pages ) : ?>
150 147 <div class="woocommerce-pagination woocommerce-pagination--without-numbers woocommerce-Pagination">
151 148 <?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>
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>
153 150 <?php endif; ?>
154 151
155 152 <?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>
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>
157 154 <?php endif; ?>
158 155 </div>
159 156 <?php endif; ?>