| @@ -39,8 +39,9 @@ | ||
| 39 | 39 | 'pending' => 'pending', |
| 40 | 40 | 'pe_cancelled' => 'pending-cancel', |
| 41 | 41 | 'cancelled' => 'cancelled', |
| 42 | 42 | 'expired' => 'expired', |
| 43 | + 'completed' => 'completed', | |
| 43 | 44 | 'draft' => 'draft', |
| 44 | 45 | 'trash' => 'trash', |
| 45 | 46 | ); |
| 46 | 47 | $badge_mod = $badge_mod_map[ $subscrpt_status ] ?? 'expired'; |
| @@ -67,9 +68,11 @@ | ||
| 67 | 68 | /* translators: %s: Subscription ID */ |
| 68 | 69 | : sprintf( __( 'Subscription #%s', 'subscription' ), $subscription_id ); |
| 69 | 70 | |
| 70 | 71 | $next_payment_date = $subscription_data['next_date'] ?? ''; |
| 71 | -$next_payment_date = ! empty( $next_payment_date ) ? wp_date( get_option( 'date_format' ), strtotime( $next_payment_date ) ) : ''; | |
| 72 | +$next_payment_date = ! empty( $next_payment_date ) && Helper::has_next_payment( $subscription_data['status'] ?? '' ) | |
| 73 | + ? wp_date( get_option( 'date_format' ), strtotime( $next_payment_date ) ) | |
| 74 | + : ''; | |
| 72 | 75 | |
| 73 | 76 | $header_badge = '<span class="wpsubs-badge wpsubs-badge--' . esc_attr( $badge_mod ) . '">' . esc_html( $verbose_status ); |
| 74 | 77 | if ( $is_grace_period && $grace_remaining > 0 ) { |
| 75 | 78 | /* translators: %d: days remaining */ |
| @@ -102,11 +105,12 @@ | ||
| 102 | 105 | $timing_per = (int) ( $subscription_data['schedule']['timing_per'] ?? 1 ); |
| 103 | 106 | $timing_option = $subscription_data['schedule']['timing_option'] ?? ''; |
| 104 | 107 | $period_label = ''; |
| 105 | 108 | if ( $timing_option ) { |
| 109 | + $timing_unit = ucfirst( Helper::get_typos( $timing_per, $timing_option ) ); | |
| 106 | 110 | $period_label = $timing_per > 1 |
| 107 | - ? $timing_per . ' ' . ucfirst( $timing_option ) . 's' | |
| 108 | - : ucfirst( $timing_option ); | |
| 111 | + ? $timing_per . ' ' . $timing_unit | |
| 112 | + : $timing_unit; | |
| 109 | 113 | } |
| 110 | 114 | |
| 111 | 115 | // Net of any discount that carries into renewals, with the original struck through. |
| 112 | 116 | $recurring_totals = Helper::get_subscription_display_totals( $subscription_id, $order_item ); |
| @@ -134,14 +138,13 @@ | ||
| 134 | 138 | 'label' => __( 'Started', 'subscription' ), |
| 135 | 139 | 'value' => esc_html( wp_date( get_option( 'date_format' ), strtotime( $subscription_data['start_date'] ) ) ), |
| 136 | 140 | ); |
| 137 | 141 | } |
| 138 | -if ( ! empty( $subscription_data['next_date'] ) ) { | |
| 139 | - $summary_tiles[] = array( | |
| 140 | - 'label' => __( 'Next Payment', 'subscription' ), | |
| 141 | - 'value' => esc_html( wp_date( get_option( 'date_format' ), strtotime( $subscription_data['next_date'] ) ) ), | |
| 142 | - ); | |
| 143 | -} | |
| 142 | +// Always show the Next Payment tile; dash when there is no next date. | |
| 143 | +$summary_tiles[] = array( | |
| 144 | + 'label' => __( 'Next Payment', 'subscription' ), | |
| 145 | + 'value' => $next_payment_date ? esc_html( $next_payment_date ) : '-', | |
| 146 | +); | |
| 144 | 147 | // Total payments is not part of $subscription_data; pull it from the info rows. |
| 145 | 148 | if ( isset( $rows['total_payments'] ) ) { |
| 146 | 149 | $summary_tiles[] = array( |
| 147 | 150 | 'label' => __( 'Total Payments', 'subscription' ), |
| @@ -162,8 +165,9 @@ | ||
| 162 | 165 | |
| 163 | 166 | // Plan card: product + qty render side by side; trial/signup fee as extra rows. |
| 164 | 167 | $plan_product = isset( $rows['product'] ) ? $rows['product']['value'] : ''; |
| 165 | 168 | $plan_qty = isset( $rows['quantity'] ) ? $rows['quantity']['value'] : ''; |
| 169 | +$plan_label = function_exists( 'subscrpt_get_subscription_plan_label' ) ? subscrpt_get_subscription_plan_label( $subscription_id ) : ''; | |
| 166 | 170 | $plan_extra = array(); |
| 167 | 171 | foreach ( array( 'product', 'quantity', 'signup_fee', 'trial', 'trial_period' ) as $plan_key ) { |
| 168 | 172 | $used_keys[ $plan_key ] = true; |
| 169 | 173 | if ( in_array( $plan_key, array( 'signup_fee', 'trial', 'trial_period' ), true ) && isset( $rows[ $plan_key ] ) ) { |
| @@ -265,8 +269,18 @@ | ||
| 265 | 269 | 'label' => ucfirst( str_replace( '-', ' ', (string) $history->type ) ), |
| 266 | 270 | ); |
| 267 | 271 | } |
| 268 | 272 | |
| 273 | +/* | |
| 274 | + * Sequence number within this subscription: 1 = first (parent) order, then each | |
| 275 | + * renewal in order. Helper::get_related_orders() returns newest-first, so the | |
| 276 | + * sequence counts down across the rendered rows. | |
| 277 | + */ | |
| 278 | +$related_count = count( $related_rows ); | |
| 279 | +foreach ( array_keys( $related_rows ) as $related_index ) { | |
| 280 | + $related_rows[ $related_index ]['seq'] = $related_count - $related_index; | |
| 281 | +} | |
| 282 | + | |
| 269 | 283 | // Reusable per-page + date toolbar for the paginated tables. Uses the admin |
| 270 | 284 | // advanced-select component; the date options are injected client-side from the |
| 271 | 285 | // table's date column. |
| 272 | 286 | $subscrpt_render_table_tools = function () { |
| @@ -287,32 +301,13 @@ | ||
| 287 | 301 | ), |
| 288 | 302 | ), |
| 289 | 303 | ) |
| 290 | 304 | ); |
| 291 | - wpsubs_render_adv_select( | |
| 305 | + wpsubs_render_per_page_select( | |
| 292 | 306 | array( |
| 293 | - 'name' => 'subscrpt_per_page', | |
| 294 | - 'value' => '10', | |
| 295 | - 'align' => 'right', | |
| 296 | - 'class' => 'subscrpt-filter-perpage', | |
| 297 | - 'options' => array( | |
| 298 | - array( | |
| 299 | - 'value' => '10', | |
| 300 | - 'label' => __( '10 / page', 'subscription' ), | |
| 301 | - ), | |
| 302 | - array( | |
| 303 | - 'value' => '20', | |
| 304 | - 'label' => __( '20 / page', 'subscription' ), | |
| 305 | - ), | |
| 306 | - array( | |
| 307 | - 'value' => '50', | |
| 308 | - 'label' => __( '50 / page', 'subscription' ), | |
| 309 | - ), | |
| 310 | - array( | |
| 311 | - 'value' => '100', | |
| 312 | - 'label' => __( '100 / page', 'subscription' ), | |
| 313 | - ), | |
| 314 | - ), | |
| 307 | + 'name' => 'subscrpt_per_page', | |
| 308 | + 'align' => 'right', | |
| 309 | + 'class' => 'subscrpt-filter-perpage', | |
| 315 | 310 | ) |
| 316 | 311 | ); |
| 317 | 312 | ?> |
| 318 | 313 | </div> |
| @@ -419,8 +414,16 @@ | ||
| 419 | 414 | <?php endif; ?> |
| 420 | 415 | </div> |
| 421 | 416 | <div class="subscrpt-plan-meta"> |
| 422 | 417 | <span class="subscrpt-plan-name"><?php echo $plan_product ? wp_kses_post( $plan_product ) : '—'; ?></span> |
| 418 | + <?php if ( $plan_label ) : ?> | |
| 419 | + <span class="subscrpt-plan-term"> | |
| 420 | + <?php | |
| 421 | + /* translators: %s: plan name */ | |
| 422 | + printf( esc_html__( 'Plan: %s', 'subscription' ), esc_html( $plan_label ) ); | |
| 423 | + ?> | |
| 424 | + </span> | |
| 425 | + <?php endif; ?> | |
| 423 | 426 | <span class="subscrpt-plan-qty"> |
| 424 | 427 | <?php |
| 425 | 428 | /* translators: %s: quantity */ |
| 426 | 429 | printf( esc_html__( 'Quantity: %s', 'subscription' ), $plan_qty ? wp_kses_post( $plan_qty ) : '1' ); |
| @@ -502,9 +505,9 @@ | ||
| 502 | 505 | </div> |
| 503 | 506 | <?php endif; ?> |
| 504 | 507 | |
| 505 | 508 | <!-- Related orders card --> |
| 506 | - <div class="subscrpt-card" data-subscrpt-paginate data-per-page="10" data-date-col="2"> | |
| 509 | + <div class="subscrpt-card" data-subscrpt-paginate data-per-page="10" data-date-col="3"> | |
| 507 | 510 | <div class="subscrpt-card__head subscrpt-card__head--toolbar"> |
| 508 | 511 | <span class="subscrpt-card__title"><?php esc_html_e( 'Related Orders', 'subscription' ); ?></span> |
| 509 | 512 | <?php if ( ! empty( $related_rows ) ) : ?> |
| 510 | 513 | <?php $subscrpt_render_table_tools(); ?> |
| @@ -513,13 +516,13 @@ | ||
| 513 | 516 | <?php if ( ! empty( $related_rows ) ) : ?> |
| 514 | 517 | <table class="wpsubs-table subscrpt-table--compact"> |
| 515 | 518 | <thead> |
| 516 | 519 | <tr> |
| 520 | + <th><?php esc_html_e( '#', 'subscription' ); ?></th> | |
| 517 | 521 | <th><?php esc_html_e( 'Order', 'subscription' ); ?></th> |
| 518 | 522 | <th><?php esc_html_e( 'Type', 'subscription' ); ?></th> |
| 519 | 523 | <th><?php esc_html_e( 'Date', 'subscription' ); ?></th> |
| 520 | 524 | <th><?php esc_html_e( 'Status', 'subscription' ); ?></th> |
| 521 | - <th><?php esc_html_e( 'Items', 'subscription' ); ?></th> | |
| 522 | 525 | <th><?php esc_html_e( 'Payment', 'subscription' ); ?></th> |
| 523 | 526 | <th><?php esc_html_e( 'Total', 'subscription' ); ?></th> |
| 524 | 527 | </tr> |
| 525 | 528 | </thead> |
| @@ -542,17 +545,19 @@ | ||
| 542 | 545 | $related_status = $related_order->get_status(); |
| 543 | 546 | $badge_class = $order_badge_map[ $related_status ] ?? 'draft'; |
| 544 | 547 | ?> |
| 545 | 548 | <tr> |
| 549 | + <td><span class="wpsubs-cell-title"><?php echo esc_html( number_format_i18n( $related['seq'] ) ); ?></span></td> | |
| 546 | 550 | <td> |
| 547 | - <a href="<?php echo esc_url( $related_order->get_edit_order_url() ); ?>" target="_blank" class="wpsubs-cell-title"> | |
| 548 | - #<?php echo esc_html( $related_order->get_order_number() ); ?> | |
| 549 | - </a> | |
| 551 | + <?php | |
| 552 | + // translators: %s: WooCommerce order number. | |
| 553 | + $order_id_label = sprintf( __( 'Order ID: #%s', 'subscription' ), $related_order->get_order_number() ); | |
| 554 | + ?> | |
| 555 | + <a href="<?php echo esc_url( $related_order->get_edit_order_url() ); ?>" target="_blank" class="wpsubs-cell-title" title="<?php echo esc_attr( $order_id_label ); ?>">#<?php echo esc_html( $related_order->get_order_number() ); ?></a> | |
| 550 | 556 | </td> |
| 551 | 557 | <td><?php echo esc_html( $related['label'] ); ?></td> |
| 552 | 558 | <td><?php echo esc_html( $related_order->get_date_created()->date( get_option( 'date_format' ) . ' - ' . get_option( 'time_format' ) ) ); ?></td> |
| 553 | 559 | <td><span class="wpsubs-badge wpsubs-badge--<?php echo esc_attr( $badge_class ); ?>"><?php echo esc_html( wc_get_order_status_name( $related_status ) ); ?></span></td> |
| 554 | - <td><?php echo esc_html( number_format_i18n( $related_order->get_item_count() ) ); ?></td> | |
| 555 | 560 | <td><?php echo $related_order->get_payment_method_title() ? esc_html( $related_order->get_payment_method_title() ) : '—'; ?></td> |
| 556 | 561 | <td><?php echo wp_kses_post( $related_order->get_formatted_order_total() ); ?></td> |
| 557 | 562 | </tr> |
| 558 | 563 | <?php endforeach; ?> |
| @@ -627,9 +632,9 @@ | ||
| 627 | 632 | <div> |
| 628 | 633 | <strong><?php esc_html_e( 'Upgrade to WPSubscription Pro', 'subscription' ); ?></strong> |
| 629 | 634 | <p><?php esc_html_e( 'Track subscription activity history, automation, and more.', 'subscription' ); ?></p> |
| 630 | 635 | </div> |
| 631 | - <a href="https://wpsubscription.co/" target="_blank" class="wpsubs-btn wpsubs-btn--primary wpsubs-btn--sm" rel="noreferrer noopener"> | |
| 636 | + <a href="https://wpsubscription.co/?utm_source=plugin&utm_medium=admin&utm_campaign=upgrade_pro" target="_blank" class="wpsubs-btn wpsubs-btn--primary wpsubs-btn--sm" rel="noreferrer noopener"> | |
| 632 | 637 | <?php esc_html_e( 'Upgrade to Pro', 'subscription' ); ?> |
| 633 | 638 | </a> |
| 634 | 639 | </div> |
| 635 | 640 | </div> |
| @@ -761,12 +766,13 @@ | ||
| 761 | 766 | |
| 762 | 767 | </div> |
| 763 | 768 | |
| 764 | 769 | <style> |
| 765 | -/* Page sits on WP admin gray; the cards are the white surfaces (matches list/health pages). */ | |
| 770 | +/* Page sits on WP admin gray; the cards are the white surfaces (matches list/health pages). | |
| 771 | + No `padding: 0` here — that overrode `.list-page`'s own `0 24px` and ran the | |
| 772 | + whole page flush into the admin menu and the right edge of the window. */ | |
| 766 | 773 | .wp-subscription-admin-content.list-page.subscrpt-subs-details { |
| 767 | 774 | background: transparent; |
| 768 | - padding: 0; | |
| 769 | 775 | border-radius: 0; |
| 770 | 776 | margin-top: 24px; |
| 771 | 777 | margin-bottom: 32px; |
| 772 | 778 | } |
| @@ -998,8 +1004,9 @@ | ||
| 998 | 1004 | .subscrpt-plan-name { font-size: 14px; font-weight: 600; color: var(--wpsubs-text); line-height: 1.3; } |
| 999 | 1005 | .subscrpt-plan-name a { color: var(--wpsubs-text); text-decoration: none; } |
| 1000 | 1006 | .subscrpt-plan-name a:hover { color: var(--wpsubs-brand); } |
| 1001 | 1007 | .subscrpt-plan-qty { font-size: 13px; color: var(--wpsubs-text-muted); } |
| 1008 | +.subscrpt-plan-term { font-size: 13px; color: var(--wpsubs-text-muted); } | |
| 1002 | 1009 | .subscrpt-plan-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; } |
| 1003 | 1010 | .subscrpt-plan-label { |
| 1004 | 1011 | font-size: 11px; |
| 1005 | 1012 | font-weight: 600; |