PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.3.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.3.0
2.4.0 2.3.0 2.2.0 2.1.0 2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 All 65 releases
← All changes | templates/myaccount/subscriptions.php +98 -35 1.3.0 → 2.3.0 View file →
@@ -2,27 +2,28 @@
2 2 /**
3 3 * Subscriptions Table
4 4 *
5 5 * @var int $current_page
6 - * @var \WP_Query $postslist
6 + * @var WP_Query $postslist
7 7 *
8 - * This template can be overridden by copying it to yourtheme/simple-booking/myaccount/subscriptions.php
9 - *
10 - * @package SpringDevs\Subscription
8 + * This template can be overridden by copying it to <your_theme>/subscription/myaccount/subscriptions.php
11 9 */
12 10
13 -use SpringDevs\Subscription\Illuminate\Helper;
11 +// Exit if accessed directly.
12 +if ( ! defined( 'ABSPATH' ) ) {
13 + exit;
14 +}
14 15 ?>
15 16
16 17 <table class="woocommerce-orders-table woocommerce-MyAccount-orders shop_table shop_table_responsive my_account_orders account-orders-table my_account_subscrpt">
17 18 <thead>
18 19 <tr>
19 - <th scope="col" class="subscrpt-id"><?php esc_html_e( 'Subscription', 'sdevs_subscrpt' ); ?></th>
20 - <th scope="col" class="order-status"><?php esc_html_e( 'Status', 'sdevs_subscrpt' ); ?></th>
21 - <th scope="col" class="order-product"><?php esc_html_e( 'Product', 'sdevs_subscrpt' ); ?></th>
22 - <th scope="col" class="subscrpt-next-date"><?php esc_html_e( 'Next Payment', 'sdevs_subscrpt' ); ?></th>
23 - <th scope="col" class="subscrpt-total"><?php esc_html_e( 'Total', 'sdevs_subscrpt' ); ?></th>
24 - <th scope="col" class="subscrpt-action"></th>
20 + <th scope="col" class="subscrpt-id"><?php esc_html_e( 'Subscription', 'subscription' ); ?></th>
21 + <th scope="col" class="order-status"><?php esc_html_e( 'Status', 'subscription' ); ?></th>
22 + <th scope="col" class="order-product"><?php esc_html_e( 'Product', 'subscription' ); ?></th>
23 + <th scope="col" class="subscrpt-next-date"><?php esc_html_e( 'Next Payment', 'subscription' ); ?></th>
24 + <th scope="col" class="subscrpt-total"><?php esc_html_e( 'Total', 'subscription' ); ?></th>
25 + <th scope="col" class="subscrpt-action">Actions</th>
25 26 </tr>
26 27 </thead>
27 28 <tbody>
28 29 <?php
@@ -28,36 +29,98 @@
28 29 <?php
29 30 if ( $postslist->have_posts() ) :
30 31 while ( $postslist->have_posts() ) :
31 32 $postslist->the_post();
32 - $product_id = get_post_meta( get_the_ID(), '_subscrpt_product_id', true );
33 - $order_id = get_post_meta( get_the_ID(), '_subscrpt_order_id', true );
34 - $order_item_id = get_post_meta( get_the_ID(), '_subscrpt_order_item_id', true );
35 - $trial = get_post_meta( get_the_ID(), '_subscrpt_trial', true );
36 - $trial_mode = get_post_meta( get_the_ID(), '_subscrpt_trial_mode', true );
37 - $trial_mode = empty( $trial_mode ) ? 'off' : $trial_mode;
38 - $start_date = get_post_meta( get_the_ID(), '_subscrpt_start_date', true );
39 - $next_date = get_post_meta( get_the_ID(), '_subscrpt_next_date', true );
40 - $order = wc_get_order( $order_id );
41 - $order_item = $order->get_item( $order_item_id );
42 33
43 - $post_status_object = get_post_status_object( get_post_status() );
44 - $product_name = $order_item->get_name();
45 - $product_link = get_the_permalink( $product_id );
46 - $product_price_html = Helper::format_price_with_order_item( get_post_meta( get_the_ID(), '_subscrpt_price', true ), $order_item->get_id() );
34 + $subscription_id = get_the_ID();
35 + $subscription_data = SpringDevs\Subscription\Illuminate\Helper::get_subscription_data( $subscription_id );
36 +
37 + if ( ! $subscription_data ) {
38 + continue;
39 + }
40 +
41 + $subscrpt_status = $subscription_data['status'] ?? '';
42 + $verbose_status = SpringDevs\Subscription\Illuminate\Helper::get_verbose_status( $subscrpt_status );
43 +
44 + $order_id = $subscription_data['order']['order_id'] ?? 0;
45 + $order_item_id = $subscription_data['order']['order_item_id'] ?? 0;
46 +
47 + $order = wc_get_order( $order_id );
48 + $order_item = $order ? $order->get_item( $order_item_id ) : null;
49 +
50 + if ( ! $order || ! $order_item ) {
51 + subscrpt_write_log( sprintf( 'Order or order item not found for subscription #%d', $subscription_id ) );
52 + continue;
53 + }
54 +
55 + $product_id = $subscription_data['product']['product_id'] ?? 0;
56 + $product_name = $order_item->get_name();
57 +
58 + $start_date = $subscription_data['start_date'] ?? '';
59 + $start_date = ! empty( $start_date ) ? wp_date( 'F j, Y', strtotime( $start_date ) ) : '-';
60 +
61 + $next_date = $subscription_data['next_date'] ?? '';
62 + $next_date = ! empty( $next_date ) && SpringDevs\Subscription\Illuminate\Helper::has_next_payment( $subscrpt_status ) ? wp_date( 'F j, Y', strtotime( $next_date ) ) : '-';
63 +
64 + $trial = get_post_meta( get_the_ID(), '_subscrpt_trial', true );
65 + $trial_mode = get_post_meta( get_the_ID(), '_subscrpt_trial_mode', true );
66 + $trial_mode = empty( $trial_mode ) ? 'off' : $trial_mode;
67 +
68 + // Renewal total, already net of any discount that recurs.
69 + $display_totals = SpringDevs\Subscription\Illuminate\Helper::get_subscription_display_totals( $subscription_id, $order_item );
70 + $price = $display_totals['total'];
71 +
72 + $product_price_html = SpringDevs\Subscription\Illuminate\Helper::format_price_with_order_item( $price, $order_item->get_id() );
73 +
74 + $is_grace_period = isset( $subscription_data['grace_period'] );
75 + $grace_remaining = $subscription_data['grace_period']['remaining_days'] ?? 0;
76 +
77 + $my_account_page_id = get_option( 'woocommerce_myaccount_page_id' );
78 + $my_account_url = get_permalink( $my_account_page_id );
79 + $view_sub_endpoint = SpringDevs\Subscription\Illuminate\Subscription\Subscription::get_user_endpoint( 'view_subs' );
80 + $view_sub_url = wc_get_endpoint_url( $view_sub_endpoint, get_the_ID(), $my_account_url );
47 81 ?>
82 +
48 83 <tr>
49 84 <td data-title="Subscription"><?php the_ID(); ?></td>
50 - <td data-title="Status"><span class="subscrpt-<?php echo esc_attr( $post_status_object->name ); ?>"><?php echo esc_html( strlen( $post_status_object->label ) > 9 ? substr( $post_status_object->label, 0, 6 ) . '...' : $post_status_object->label ); ?></span></td>
51 - <td data-title="Product"><a href="<?php echo esc_html( $product_link ); ?>" target="_blank"><?php echo esc_html( $product_name ); ?></a></td>
52 - <?php if ( 'on' !== $trial_mode ) : ?>
53 - <td data-title="Next Payment"><?php echo esc_html( $next_date ? gmdate( 'F d, Y', $next_date ) : '-' ); ?></td>
85 +
86 + <td data-title="Status">
87 + <?php if ( $is_grace_period && $grace_remaining > 0 ) : ?>
88 + <span class="subscrpt-legacy-status subscrpt-legacy-status--active grace-active">
89 + Active
90 +
91 + <?php
92 + $grace_remaining_text = sprintf(
93 + // translators: Number of days remaining in grace period.
94 + __( '%d days remaining!', 'subscription' ),
95 + $grace_remaining
96 + );
97 + ?>
98 + <span class="grace-icon" data-tooltip="<?php echo esc_attr( $grace_remaining_text ); ?>">
99 + <span class="dashicons dashicons-warning"></span>
100 + </span>
101 + </span>
102 + <?php else : ?>
103 + <span class="subscrpt-legacy-status subscrpt-legacy-status--<?php echo esc_attr( strtolower( $subscrpt_status ) ); ?>">
104 + <?php echo esc_html( strlen( $verbose_status ) > 9 ? substr( $verbose_status, 0, 9 ) . '...' : $verbose_status ); ?>
105 + </span>
106 + <?php endif; ?>
107 + </td>
108 +
109 + <td data-title="Product"><?php echo esc_html( $product_name ); ?></td>
110 +
111 + <?php if ( 'on' !== $trial_mode || ! SpringDevs\Subscription\Illuminate\Helper::has_next_payment( $subscrpt_status ) ) : ?>
112 + <td data-title="Next Payment"><?php echo esc_html( $next_date ); ?></td>
54 113 <?php else : ?>
55 - <td data-title="Next Payment"><small>First Billing : </small><?php echo esc_html( gmdate( 'F d, Y', $start_date ) ); ?></td>
114 + <td data-title="Next Payment"><small>First Billing : </small><?php echo esc_html( $start_date ); ?></td>
56 115 <?php endif; ?>
116 +
57 117 <td data-title="Total"><?php echo wp_kses_post( $product_price_html ); ?></td>
58 - <td data-title="Actions">
59 - <a href="<?php echo esc_html( wc_get_endpoint_url( 'view-subscription', get_the_ID(), wc_get_page_permalink( 'myaccount' ) ) ); ?>" class="woocommerce-button <?php echo esc_attr( $wp_button_class ); ?> button view"><span class="dashicons dashicons-visibility"></span></a>
118 +
119 + <td data-title="Actions">
120 + <a href="<?php echo esc_url( $view_sub_url ); ?>" class="woocommerce-button <?php echo esc_attr( $wp_button_class ); ?> button view">
121 + <?php echo esc_html_e( 'View', 'subscription' ); ?>
122 + </a>
60 123 </td>
61 124 </tr>
62 125 <?php
63 126 endwhile;
@@ -66,9 +129,9 @@
66 129 ?>
67 130 <tr>
68 131 <td colspan="6">
69 132 <p style="text-align: center;">
70 - <?php echo esc_html_e( 'No subscriptions available yet.', 'sdevs_subscrpt' ); ?>
133 + <?php echo esc_html_e( 'No subscriptions available yet.', 'subscription' ); ?>
71 134 </p>
72 135 </td>
73 136 </tr>
74 137 <?php
@@ -79,12 +142,12 @@
79 142
80 143 <?php if ( 1 < $postslist->max_num_pages ) : ?>
81 144 <div class="woocommerce-pagination woocommerce-pagination--without-numbers woocommerce-Pagination">
82 145 <?php if ( 1 !== $current_page ) : ?>
83 - <a class="woocommerce-button woocommerce-button--previous woocommerce-Button woocommerce-Button--previous button<?php echo esc_attr( $wp_button_class ); ?>" href="<?php echo esc_url( wc_get_endpoint_url( 'subscriptions', $current_page - 1 ) ); ?>"><?php esc_html_e( 'Previous', 'sdevs_subscrpt' ); ?></a>
146 + <a class="woocommerce-button woocommerce-button--previous woocommerce-Button woocommerce-Button--previous button<?php echo esc_attr( $wp_button_class ); ?>" href="<?php echo esc_url( wc_get_endpoint_url( 'subscriptions', $current_page - 1 ) ); ?>"><?php esc_html_e( 'Previous', 'subscription' ); ?></a>
84 147 <?php endif; ?>
85 148
86 149 <?php if ( intval( $postslist->max_num_pages ) !== $current_page ) : ?>
87 - <a class="woocommerce-button woocommerce-button--next woocommerce-Button woocommerce-Button--next button<?php echo esc_attr( $wp_button_class ); ?>" href="<?php echo esc_url( wc_get_endpoint_url( 'subscriptions', $current_page + 1 ) ); ?>"><?php esc_html_e( 'Next', 'sdevs_subscrpt' ); ?></a>
150 + <a class="woocommerce-button woocommerce-button--next woocommerce-Button woocommerce-Button--next button<?php echo esc_attr( $wp_button_class ); ?>" href="<?php echo esc_url( wc_get_endpoint_url( 'subscriptions', $current_page + 1 ) ); ?>"><?php esc_html_e( 'Next', 'subscription' ); ?></a>
88 151 <?php endif; ?>
89 152 </div>
90 153 <?php endif; ?>