| @@ -16,8 +16,12 @@ | ||
| 16 | 16 | * @var string $status |
| 17 | 17 | * @var array $action_buttons |
| 18 | 18 | * @var bool $is_grace_period |
| 19 | 19 | * @var int $grace_remaining |
| 20 | + * @var float $price Renewal total, after any discount that recurs. | |
| 21 | + * @var float $price_excl_tax Renewal subtotal before discount and tax. | |
| 22 | + * @var float $tax Tax on the discounted renewal amount. | |
| 23 | + * @var float $discount Discount that applies to each renewal. 0 when none recurs. | |
| 20 | 24 | * |
| 21 | 25 | * This template can be overridden by copying it to <your_theme>/subscription/myaccount/single.php |
| 22 | 26 | * |
| 23 | 27 | * @package SpringDevs\Subscription |
| @@ -45,8 +49,14 @@ | ||
| 45 | 49 | display: flex; |
| 46 | 50 | flex-wrap: wrap; |
| 47 | 51 | gap: 10px; |
| 48 | 52 | } |
| 53 | + .product-name .subscrpt-plan-term { | |
| 54 | + display: block; | |
| 55 | + margin-top: 4px; | |
| 56 | + font-size: 13px; | |
| 57 | + color: #6b7280; | |
| 58 | + } | |
| 49 | 59 | </style> |
| 50 | 60 | <table class="woocommerce-table woocommerce-table--order-details shop_table order_details subscription_details"> |
| 51 | 61 | <tbody> |
| 52 | 62 | <tr> |
| @@ -105,9 +115,9 @@ | ||
| 105 | 115 | ?> |
| 106 | 116 | </td> |
| 107 | 117 | <td><?php echo esc_html( $start_date ); ?></td> |
| 108 | 118 | </tr> |
| 109 | - <?php if ( null == $trial || in_array( $trial_mode, array( 'off', 'extended' ), true ) ) : ?> | |
| 119 | + <?php if ( ( null == $trial || in_array( $trial_mode, array( 'off', 'extended' ), true ) ) && get_post_meta( $id, '_subscrpt_next_date', true ) ) : ?> | |
| 110 | 120 | <tr> |
| 111 | 121 | <td> |
| 112 | 122 | <?php |
| 113 | 123 | esc_html_e( 'Next payment date', 'subscription' ); |
| @@ -199,11 +209,14 @@ | ||
| 199 | 209 | |
| 200 | 210 | <!-- Access Duration Information for Split Payments --> |
| 201 | 211 | <?php if ( 'split_payment' === $payment_type && $max_payments > 0 ) : ?> |
| 202 | 212 | <?php |
| 203 | - $access_ends_timing = get_post_meta( $product_id, '_subscrpt_access_ends_timing', true ) ?: 'after_full_duration'; | |
| 204 | - $custom_duration_time = get_post_meta( $product_id, '_subscrpt_custom_access_duration_time', true ) ?: 1; | |
| 205 | - $custom_duration_type = get_post_meta( $product_id, '_subscrpt_custom_access_duration_type', true ) ?: 'months'; | |
| 213 | + // Plan subscriptions store access-ends on the subscription; classic ones on | |
| 214 | + // the product. Prefer the subscription meta, fall back to the product. | |
| 215 | + $access_ends_timing = get_post_meta( $id, '_subscrpt_access_ends_timing', true ); | |
| 216 | + $access_ends_timing = $access_ends_timing ? $access_ends_timing : ( get_post_meta( $product_id, '_subscrpt_access_ends_timing', true ) ?: 'after_full_duration' ); | |
| 217 | + $custom_duration_time = get_post_meta( $id, '_subscrpt_custom_access_duration_time', true ) ?: ( get_post_meta( $product_id, '_subscrpt_custom_access_duration_time', true ) ?: 1 ); | |
| 218 | + $custom_duration_type = get_post_meta( $id, '_subscrpt_custom_access_duration_type', true ) ?: ( get_post_meta( $product_id, '_subscrpt_custom_access_duration_type', true ) ?: 'months' ); | |
| 206 | 219 | |
| 207 | 220 | // Calculate access end date if Pro version is available |
| 208 | 221 | $access_end_date_string = null; |
| 209 | 222 | if ( function_exists( 'subscrpt_pro_activated' ) && subscrpt_pro_activated() ) { |
| @@ -296,8 +309,14 @@ | ||
| 296 | 309 | <tr class="order_item"> |
| 297 | 310 | <td class="product-name"> |
| 298 | 311 | <a href="<?php echo esc_html( $product_link ); ?>"><?php echo esc_html( $product_name ); ?></a> |
| 299 | 312 | <strong class="product-quantity">× <?php echo esc_html( $order_item->get_quantity() ); ?></strong> |
| 313 | + <?php | |
| 314 | + $plan_label = function_exists( 'subscrpt_get_subscription_plan_label' ) ? subscrpt_get_subscription_plan_label( $id ) : ''; | |
| 315 | + if ( $plan_label ) : | |
| 316 | + ?> | |
| 317 | + <span class="subscrpt-plan-term"><?php printf( /* translators: %s: plan name. */ esc_html__( 'Plan: %s', 'subscription' ), esc_html( $plan_label ) ); ?></span> | |
| 318 | + <?php endif; ?> | |
| 300 | 319 | </td> |
| 301 | 320 | <td class="product-total"> |
| 302 | 321 | <span class="woocommerce-Price-amount amount"> |
| 303 | 322 | <?php |
| @@ -318,8 +337,24 @@ | ||
| 318 | 337 | </span> |
| 319 | 338 | </td> |
| 320 | 339 | </tr> |
| 321 | 340 | |
| 341 | + <?php if ( ! empty( $discount ) && $discount > 0 ) : ?> | |
| 342 | + <tr class="subscrpt-recurring-discount"> | |
| 343 | + <th scope="row"><?php esc_html_e( 'Discount', 'subscription' ); ?>:</th> | |
| 344 | + <td> | |
| 345 | + <span class="woocommerce-Price-amount amount"> | |
| 346 | + <?php | |
| 347 | + printf( | |
| 348 | + '-%s', | |
| 349 | + wp_kses_post( wc_price( $discount, array( 'currency' => $order->get_currency() ) ) ) | |
| 350 | + ); | |
| 351 | + ?> | |
| 352 | + </span> | |
| 353 | + </td> | |
| 354 | + </tr> | |
| 355 | + <?php endif; ?> | |
| 356 | + | |
| 322 | 357 | <?php if ( $tax > 0 ) : ?> |
| 323 | 358 | <tr> |
| 324 | 359 | <th scope="row"><?php esc_html_e( 'Tax', 'subscription' ); ?>:</th> |
| 325 | 360 | <td> |
| @@ -343,13 +378,28 @@ | ||
| 343 | 378 | |
| 344 | 379 | <?php do_action( 'subscrpt_after_subscription_totals', (int) $id ); ?> |
| 345 | 380 | |
| 346 | 381 | <!-- Show related subscription orders --> |
| 382 | +<?php | |
| 383 | +/* | |
| 384 | + * Sequence number within this subscription: 1 = first (parent) order, then each | |
| 385 | + * renewal in order. Helper::get_related_orders() returns newest-first, so the | |
| 386 | + * map is built from the reversed list. Relations whose order no longer exists | |
| 387 | + * are skipped here as well, keeping the numbering gapless with the rendered rows. | |
| 388 | + */ | |
| 389 | +$related_order_seq = []; | |
| 390 | +foreach ( array_reverse( $related_orders ) as $subscrpt_relation ) { | |
| 391 | + if ( isset( $related_order_seq[ $subscrpt_relation->order_id ] ) || ! wc_get_order( $subscrpt_relation->order_id ) ) { | |
| 392 | + continue; | |
| 393 | + } | |
| 394 | + $related_order_seq[ $subscrpt_relation->order_id ] = count( $related_order_seq ) + 1; | |
| 395 | +} | |
| 396 | +?> | |
| 347 | 397 | <h2><?php echo esc_html_e( 'Related Orders', 'subscription' ); ?></h2> |
| 348 | 398 | <table class="woocommerce-table woocommerce-table--order-details shop_table order_details"> |
| 349 | 399 | <thead> |
| 350 | 400 | <tr> |
| 351 | - <th class="order-number"><?php echo esc_html_e( 'Order', 'subscription' ); ?></th> | |
| 401 | + <th class="order-number"><?php echo esc_html_e( '#', 'subscription' ); ?></th> | |
| 352 | 402 | <th class="order-type"><?php echo esc_html_e( 'Type', 'subscription' ); ?></th> |
| 353 | 403 | <th class="order-date"><?php echo esc_html_e( 'Date', 'subscription' ); ?></th> |
| 354 | 404 | <th class="order-status"><?php echo esc_html_e( 'Status', 'subscription' ); ?></th> |
| 355 | 405 | <th class="order-total"><?php echo esc_html_e( 'Total', 'subscription' ); ?></th> |
| @@ -385,10 +435,14 @@ | ||
| 385 | 435 | ?> |
| 386 | 436 | |
| 387 | 437 | <tr class="order_item"> |
| 388 | 438 | <td class="order-number"> |
| 389 | - <a href="<?php echo esc_url( wc_get_endpoint_url( 'view-order', $order_id, wc_get_page_permalink( 'myaccount' ) ) ); ?>"> | |
| 390 | - #<?php echo esc_html( $order_id ); ?> | |
| 439 | + <?php | |
| 440 | + // translators: %s: WooCommerce order number. | |
| 441 | + $order_number_label = sprintf( __( 'Order #%s', 'subscription' ), $order->get_order_number() ); | |
| 442 | + ?> | |
| 443 | + <a href="<?php echo esc_url( wc_get_endpoint_url( 'view-order', $order_id, wc_get_page_permalink( 'myaccount' ) ) ); ?>" title="<?php echo esc_attr( $order_number_label ); ?>" aria-label="<?php echo esc_attr( $order_number_label ); ?>"> | |
| 444 | + <?php echo esc_html( number_format_i18n( $related_order_seq[ $order_id ] ?? 0 ) ); ?> | |
| 391 | 445 | </a> |
| 392 | 446 | </td> |
| 393 | 447 | <td class="order-type"> |
| 394 | 448 | <?php echo esc_html( $order_type_label ); ?> |