PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.3.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.3.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 | includes/Frontend/MyAccount.php +18 -14 1.10.5 → 2.3.0 View file →
@@ -75,11 +75,13 @@
75 75
76 76 /**
77 77 * Display Subscription Content.
78 78 *
79 - * @param Int $id Post ID.
79 + * @param int $id Post ID.
80 80 */
81 - public function view_subscrpt_content( int $id ) {
81 + public function view_subscrpt_content( $id ) {
82 + $id = absint( $id ); // typecast to int.
83 +
82 84 $subs_post = get_post( $id );
83 85 $author_id = $subs_post ? (int) $subs_post->post_author : 0;
84 86 $current_user_id = get_current_user_id();
85 87 $user_is_admin = current_user_can( 'manage_options' );
@@ -110,24 +112,20 @@
110 112 $start_date = $subscription_data['start_date'] ?? '';
111 113 $start_date = ! empty( $start_date ) ? wp_date( 'F j, Y', strtotime( $start_date ) ) : '-';
112 114
113 115 $next_date = $subscription_data['next_date'] ?? '';
114 - $next_date = ! empty( $next_date ) ? wp_date( 'F j, Y', strtotime( $next_date ) ) : '-';
116 + $next_date = ! empty( $next_date ) && Helper::has_next_payment( $status ) ? wp_date( 'F j, Y', strtotime( $next_date ) ) : '-';
115 117
116 118 $trial = get_post_meta( $id, '_subscrpt_trial', true );
117 119 $trial_mode = get_post_meta( $id, '_subscrpt_trial_mode', true );
118 120
119 - $quantity = (int) $order_item->get_quantity();
120 - $price = (float) ( $subscription_data['price'] ?? 0 ) * max( 1, $quantity );
121 - $price_excl_tax = (float) $order_item->get_total();
122 - $tax_amount = (float) $order_item->get_total_tax();
121 + // Undiscounted subtotal, the discount that recurs, tax on the discounted amount, and the renewal total.
122 + $display_totals = Helper::get_subscription_display_totals( $id, $order_item );
123 123
124 - if ( $tax_amount > 0 ) {
125 - $price = $price_excl_tax + $tax_amount;
126 - $price = number_format( (float) $price, 2, '.', '' );
127 - } else {
128 - $tax_amount = 0;
129 - }
124 + $price = $display_totals['total'];
125 + $price_excl_tax = $display_totals['full_excl'];
126 + $tax_amount = $display_totals['tax'];
127 + $discount = $display_totals['discount'];
130 128
131 129 $is_grace_period = isset( $subscription_data['grace_period'] );
132 130 $grace_remaining = $subscription_data['grace_period']['remaining_days'] ?? 0;
133 131 $grace_end_date = $subscription_data['grace_period']['end_date'] ?? '';
@@ -213,8 +211,13 @@
213 211 }
214 212
215 213 $action_buttons = apply_filters( 'subscrpt_single_action_buttons', $action_buttons, $id, $subscrpt_nonce, $status );
216 214
215 + // Nothing renews once a subscription has ended, so drop the auto-renewal toggle — Pro adds it through the filter too.
216 + if ( ! Helper::has_next_payment( $status ) ) {
217 + unset( $action_buttons['auto-renew-on'], $action_buttons['auto-renew-off'] );
218 + }
219 +
217 220 wc_get_template(
218 221 'myaccount/single.php',
219 222 array(
220 223 'id' => $id,
@@ -232,8 +235,9 @@
232 235 'related_orders' => $related_orders,
233 236 'price' => $price,
234 237 'price_excl_tax' => $price_excl_tax,
235 238 'tax' => $tax_amount,
239 + 'discount' => $discount,
236 240 'user_cancel' => $user_cancel,
237 241 'action_buttons' => $action_buttons,
238 242 'wp_button_class' => wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '',
239 243 ),
@@ -306,9 +310,9 @@
306 310 'author' => get_current_user_id(),
307 311 'posts_per_page' => 10,
308 312 'paged' => $current_page,
309 313 'post_type' => 'subscrpt_order',
310 - 'post_status' => array( 'pending', 'active', 'on_hold', 'cancelled', 'expired', 'pe_cancelled' ),
314 + 'post_status' => array( 'pending', 'active', 'on_hold', 'cancelled', 'expired', 'pe_cancelled', 'completed' ),
311 315 );
312 316
313 317 $postslist = new \WP_Query( $args );
314 318 wc_get_template(