| 1 |
<?php |
| 2 |
/** |
| 3 |
* Related Subscriptions meta box view. |
| 4 |
* |
| 5 |
* @package SpringDevs\Subscription\Admin |
| 6 |
*/ |
| 7 |
|
| 8 |
// Exit if accessed directly. |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
?> |
| 14 |
<style> |
| 15 |
.subscrpt-related-subscriptions td{ |
| 16 |
vertical-align: middle; |
| 17 |
} |
| 18 |
</style> |
| 19 |
|
| 20 |
<table class="widefat striped subscrpt-related-subscriptions"> |
| 21 |
<thead> |
| 22 |
<tr> |
| 23 |
<th><?php esc_html_e( 'ID', 'subscription' ); ?></th> |
| 24 |
<th><?php esc_html_e( 'Product', 'subscription' ); ?></th> |
| 25 |
<th><?php esc_html_e( 'Recurring', 'subscription' ); ?></th> |
| 26 |
<th><?php esc_html_e( 'Started on', 'subscription' ); ?></th> |
| 27 |
<th><?php esc_html_e( 'Expiry date', 'subscription' ); ?></th> |
| 28 |
<th><?php esc_html_e( 'Status', 'subscription' ); ?></th> |
| 29 |
</tr> |
| 30 |
</thead> |
| 31 |
<tbody> |
| 32 |
<?php |
| 33 |
foreach ( $histories as $history ) : |
| 34 |
$subscription_id = $history->subscription_id; |
| 35 |
$subscription_data = SpringDevs\Subscription\Illuminate\Helper::get_subscription_data( $subscription_id ); |
| 36 |
|
| 37 |
$subscrpt_status = $subscription_data['status'] ?? ''; |
| 38 |
$verbose_status = SpringDevs\Subscription\Illuminate\Helper::get_verbose_status( $subscrpt_status ); |
| 39 |
|
| 40 |
$order_item_id = get_post_meta( $history->subscription_id, '_subscrpt_order_item_id', true ); |
| 41 |
$order_item = $order->get_item( $history->order_item_id ); |
| 42 |
|
| 43 |
$trial = get_post_meta( $history->subscription_id, '_subscrpt_trial', true ); |
| 44 |
|
| 45 |
$start_date = $subscription_data['start_date'] ?? ''; |
| 46 |
$start_date = ! empty( $start_date ) ? wp_date( 'F j, Y - g:i A', strtotime( $start_date ) ) : '-'; |
| 47 |
|
| 48 |
$next_date = $subscription_data['next_date'] ?? ''; |
| 49 |
$next_date = ! empty( $next_date ) ? wp_date( 'F j, Y - g:i A', strtotime( $next_date ) ) : '-'; |
| 50 |
|
| 51 |
// Strikes the original amount when a discount carries into renewals. |
| 52 |
$price_html = SpringDevs\Subscription\Illuminate\Helper::get_subscription_recurring_price_html( $subscription_id, $order_item ); |
| 53 |
|
| 54 |
$is_grace_period = isset( $subscription_data['grace_period'] ); |
| 55 |
$grace_remaining = $subscription_data['grace_period']['remaining_days'] ?? 0; |
| 56 |
?> |
| 57 |
<tr> |
| 58 |
<td> |
| 59 |
<a href="<?php echo esc_html( get_edit_post_link( $subscription_id ) ); ?>" target="_blank">Subscription #<?php echo esc_html( $subscription_id ); ?></a> |
| 60 |
</td> |
| 61 |
<td> |
| 62 |
<?php echo esc_html( $order_item->get_name() ); ?> |
| 63 |
</td> |
| 64 |
<td> |
| 65 |
<?php echo wp_kses_post( $price_html ); ?> |
| 66 |
</td> |
| 67 |
<td> |
| 68 |
<?php echo esc_html( $start_date ); ?> |
| 69 |
</td> |
| 70 |
<td> |
| 71 |
<?php echo esc_html( $next_date ); ?> |
| 72 |
</td> |
| 73 |
<td> |
| 74 |
<?php if ( $is_grace_period && $grace_remaining > 0 ) : ?> |
| 75 |
<span class="subscrpt-legacy-status subscrpt-legacy-status--active grace-active"> |
| 76 |
Active |
| 77 |
|
| 78 |
<?php |
| 79 |
$grace_remaining_text = sprintf( |
| 80 |
// translators: Number of days remaining in grace period. |
| 81 |
__( '%d days remaining!', 'subscription' ), |
| 82 |
$grace_remaining |
| 83 |
); |
| 84 |
?> |
| 85 |
<span class="grace-icon" data-tooltip="<?php echo esc_attr( $grace_remaining_text ); ?>"> |
| 86 |
<span class="dashicons dashicons-warning"></span> |
| 87 |
</span> |
| 88 |
</span> |
| 89 |
<?php else : ?> |
| 90 |
<span class="subscrpt-legacy-status subscrpt-legacy-status--<?php echo esc_attr( strtolower( $subscrpt_status ) ); ?>"> |
| 91 |
<?php echo esc_html( $verbose_status ); ?> |
| 92 |
</span> |
| 93 |
<?php endif; ?> |
| 94 |
</td> |
| 95 |
</tr> |
| 96 |
<?php |
| 97 |
endforeach; |
| 98 |
?> |
| 99 |
</tbody> |
| 100 |
</table> |
| 101 |
|