| 1 |
<?php |
| 2 |
/** |
| 3 |
* Subscriptions Table |
| 4 |
* |
| 5 |
* @var int $current_page |
| 6 |
* @var WP_Query $postslist |
| 7 |
* |
| 8 |
* This template can be overridden by copying it to <your_theme>/subscription/myaccount/subscriptions.php |
| 9 |
*/ |
| 10 |
|
| 11 |
use SpringDevs\Subscription\Illuminate\Helper; |
| 12 |
?> |
| 13 |
|
| 14 |
<table class="woocommerce-orders-table woocommerce-MyAccount-orders shop_table shop_table_responsive my_account_orders account-orders-table my_account_subscrpt"> |
| 15 |
<thead> |
| 16 |
<tr> |
| 17 |
<th scope="col" class="subscrpt-id"><?php esc_html_e( 'Subscription', 'sdevs_subscrpt' ); ?></th> |
| 18 |
<th scope="col" class="order-status"><?php esc_html_e( 'Status', 'sdevs_subscrpt' ); ?></th> |
| 19 |
<th scope="col" class="order-product"><?php esc_html_e( 'Product', 'sdevs_subscrpt' ); ?></th> |
| 20 |
<th scope="col" class="subscrpt-next-date"><?php esc_html_e( 'Next Payment', 'sdevs_subscrpt' ); ?></th> |
| 21 |
<th scope="col" class="subscrpt-total"><?php esc_html_e( 'Total', 'sdevs_subscrpt' ); ?></th> |
| 22 |
<th scope="col" class="subscrpt-action"></th> |
| 23 |
</tr> |
| 24 |
</thead> |
| 25 |
<tbody> |
| 26 |
<?php |
| 27 |
if ( $postslist->have_posts() ) : |
| 28 |
while ( $postslist->have_posts() ) : |
| 29 |
$postslist->the_post(); |
| 30 |
$product_id = get_post_meta( get_the_ID(), '_subscrpt_product_id', true ); |
| 31 |
$order_id = get_post_meta( get_the_ID(), '_subscrpt_order_id', true ); |
| 32 |
$order_item_id = get_post_meta( get_the_ID(), '_subscrpt_order_item_id', true ); |
| 33 |
$trial = get_post_meta( get_the_ID(), '_subscrpt_trial', true ); |
| 34 |
$trial_mode = get_post_meta( get_the_ID(), '_subscrpt_trial_mode', true ); |
| 35 |
$trial_mode = empty( $trial_mode ) ? 'off' : $trial_mode; |
| 36 |
$start_date = get_post_meta( get_the_ID(), '_subscrpt_start_date', true ); |
| 37 |
$next_date = get_post_meta( get_the_ID(), '_subscrpt_next_date', true ); |
| 38 |
$order = wc_get_order( $order_id ); |
| 39 |
$order_item = $order->get_item( $order_item_id ); |
| 40 |
|
| 41 |
$post_status_object = get_post_status_object( get_post_status() ); |
| 42 |
$product_name = $order_item->get_name(); |
| 43 |
$product_link = get_the_permalink( $product_id ); |
| 44 |
$product_price_html = Helper::format_price_with_order_item( get_post_meta( get_the_ID(), '_subscrpt_price', true ), $order_item->get_id() ); |
| 45 |
?> |
| 46 |
<tr> |
| 47 |
<td data-title="Subscription"><?php the_ID(); ?></td> |
| 48 |
<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> |
| 49 |
<td data-title="Product"><a href="<?php echo esc_html( $product_link ); ?>" target="_blank"><?php echo esc_html( $product_name ); ?></a></td> |
| 50 |
<?php if ( 'on' !== $trial_mode ) : ?> |
| 51 |
<td data-title="Next Payment"><?php echo esc_html( $next_date ? gmdate( 'F d, Y', $next_date ) : '-' ); ?></td> |
| 52 |
<?php else : ?> |
| 53 |
<td data-title="Next Payment"><small>First Billing : </small><?php echo esc_html( gmdate( 'F d, Y', $start_date ) ); ?></td> |
| 54 |
<?php endif; ?> |
| 55 |
<td data-title="Total"><?php echo wp_kses_post( $product_price_html ); ?></td> |
| 56 |
<td data-title="Actions"> |
| 57 |
<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> |
| 58 |
</td> |
| 59 |
</tr> |
| 60 |
<?php |
| 61 |
endwhile; |
| 62 |
wp_reset_postdata(); |
| 63 |
else : |
| 64 |
?> |
| 65 |
<tr> |
| 66 |
<td colspan="6"> |
| 67 |
<p style="text-align: center;"> |
| 68 |
<?php echo esc_html_e( 'No subscriptions available yet.', 'sdevs_subscrpt' ); ?> |
| 69 |
</p> |
| 70 |
</td> |
| 71 |
</tr> |
| 72 |
<?php |
| 73 |
endif; |
| 74 |
?> |
| 75 |
</tbody> |
| 76 |
</table> |
| 77 |
|
| 78 |
<?php if ( 1 < $postslist->max_num_pages ) : ?> |
| 79 |
<div class="woocommerce-pagination woocommerce-pagination--without-numbers woocommerce-Pagination"> |
| 80 |
<?php if ( 1 !== $current_page ) : ?> |
| 81 |
<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> |
| 82 |
<?php endif; ?> |
| 83 |
|
| 84 |
<?php if ( intval( $postslist->max_num_pages ) !== $current_page ) : ?> |
| 85 |
<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> |
| 86 |
<?php endif; ?> |
| 87 |
</div> |
| 88 |
<?php endif; ?> |
| 89 |
|