my-subscriptions.php
4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* My Subscriptions section on the My Account page
*
* @author Prospress
* @category WooCommerce Subscriptions/Templates
* @version 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( WC_Subscriptions::is_woocommerce_pre( '2.6' ) ) : ?>
<div class="woocommerce_account_subscriptions">
<?php else : ?>
<div class="woocommerce-MyAccount-content woocommerce_account_subscriptions">
<?php endif; ?>
<?php if ( WC_Subscriptions::is_woocommerce_pre( '2.6' ) ) : ?>
<h2><?php esc_html_e( 'My Subscriptions', 'woocommerce-subscriptions' ); ?></h2>
<?php endif; ?>
<?php if ( ! empty( $subscriptions ) ) : ?>
<table class="shop_table shop_table_responsive my_account_subscriptions my_account_orders">
<thead>
<tr>
<th class="subscription-id order-number"><span class="nobr"><?php esc_html_e( 'Subscription', 'woocommerce-subscriptions' ); ?></span></th>
<th class="subscription-status order-status"><span class="nobr"><?php esc_html_e( 'Status', 'woocommerce-subscriptions' ); ?></span></th>
<th class="subscription-next-payment order-date"><span class="nobr"><?php echo esc_html_x( 'Next Payment', 'table heading', 'woocommerce-subscriptions' ); ?></span></th>
<th class="subscription-total order-total"><span class="nobr"><?php echo esc_html_x( 'Total', 'table heading', 'woocommerce-subscriptions' ); ?></span></th>
<th class="subscription-actions order-actions"> </th>
</tr>
</thead>
<tbody>
<?php foreach ( $subscriptions as $subscription_id => $subscription ) : ?>
<tr class="order">
<td class="subscription-id order-number" data-title="<?php esc_attr_e( 'ID', 'woocommerce-subscriptions' ); ?>">
<a href="<?php echo esc_url( $subscription->get_view_order_url() ); ?>"><?php echo esc_html( sprintf( _x( '#%s', 'hash before order number', 'woocommerce-subscriptions' ), $subscription->get_order_number() ) ); ?></a>
<?php do_action( 'woocommerce_my_subscriptions_after_subscription_id', $subscription ); ?>
</td>
<td class="subscription-status order-status" style="text-align:left; white-space:nowrap;" data-title="<?php esc_attr_e( 'Status', 'woocommerce-subscriptions' ); ?>">
<?php echo esc_attr( wcs_get_subscription_status_name( $subscription->get_status() ) ); ?>
</td>
<td class="subscription-next-payment order-date" data-title="<?php echo esc_attr_x( 'Next Payment', 'table heading', 'woocommerce-subscriptions' ); ?>">
<?php echo esc_attr( $subscription->get_date_to_display( 'next_payment' ) ); ?>
<?php if ( ! $subscription->is_manual() && $subscription->has_status( 'active' ) && $subscription->get_time( 'next_payment' ) > 0 ) : ?>
<?php
// translators: placeholder is the display name of a payment gateway a subscription was paid by
$payment_method_to_display = sprintf( __( 'Via %s', 'woocommerce-subscriptions' ), $subscription->get_payment_method_to_display() );
$payment_method_to_display = apply_filters( 'woocommerce_my_subscriptions_payment_method', $payment_method_to_display, $subscription );
?>
<br/><small><?php echo esc_attr( $payment_method_to_display ); ?></small>
<?php endif; ?>
</td>
<td class="subscription-total order-total" data-title="<?php echo esc_attr_x( 'Total', 'Used in data attribute. Escaped', 'woocommerce-subscriptions' ); ?>">
<?php echo wp_kses_post( $subscription->get_formatted_order_total() ); ?>
</td>
<td class="subscription-actions order-actions">
<a href="<?php echo esc_url( $subscription->get_view_order_url() ) ?>" class="button view"><?php echo esc_html_x( 'View', 'view a subscription', 'woocommerce-subscriptions' ); ?></a>
<?php do_action( 'woocommerce_my_subscriptions_actions', $subscription ); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else : ?>
<p class="no_subscriptions">
<?php
// translators: placeholders are opening and closing link tags to take to the shop page
printf( esc_html__( 'You have no active subscriptions. Find your first subscription in the %sstore%s.', 'woocommerce-subscriptions' ), '<a href="' . esc_url( apply_filters( 'woocommerce_subscriptions_message_store_url', get_permalink( wc_get_page_id( 'shop' ) ) ) ) . '">', '</a>' );
?>
</p>
<?php endif; ?>
</div>
<?php