| @@ -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,9 +112,9 @@ | ||
| 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 | |
| @@ -209,8 +211,13 @@ | ||
| 209 | 211 | } |
| 210 | 212 | |
| 211 | 213 | $action_buttons = apply_filters( 'subscrpt_single_action_buttons', $action_buttons, $id, $subscrpt_nonce, $status ); |
| 212 | 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 | + | |
| 213 | 220 | wc_get_template( |
| 214 | 221 | 'myaccount/single.php', |
| 215 | 222 | array( |
| 216 | 223 | 'id' => $id, |
| @@ -303,9 +310,9 @@ | ||
| 303 | 310 | 'author' => get_current_user_id(), |
| 304 | 311 | 'posts_per_page' => 10, |
| 305 | 312 | 'paged' => $current_page, |
| 306 | 313 | 'post_type' => 'subscrpt_order', |
| 307 | - 'post_status' => array( 'pending', 'active', 'on_hold', 'cancelled', 'expired', 'pe_cancelled' ), | |
| 314 | + 'post_status' => array( 'pending', 'active', 'on_hold', 'cancelled', 'expired', 'pe_cancelled', 'completed' ), | |
| 308 | 315 | ); |
| 309 | 316 | |
| 310 | 317 | $postslist = new \WP_Query( $args ); |
| 311 | 318 | wc_get_template( |