| 1 |
<?php |
| 2 |
/** |
| 3 |
* Single subscription page |
| 4 |
* |
| 5 |
* @var WC_Order $order |
| 6 |
* @var WC_Order_Item $order_item |
| 7 |
* @var string $start_date |
| 8 |
* @var string $next_date |
| 9 |
* @var string|null $trial |
| 10 |
* @var string|null $trial_mode |
| 11 |
* @var stdClass $status |
| 12 |
* @var array $action_buttons |
| 13 |
* |
| 14 |
* This template can be overridden by copying it to yourtheme/subscription/myaccount/single.php |
| 15 |
* |
| 16 |
* @package SpringDevs\Subscription |
| 17 |
*/ |
| 18 |
|
| 19 |
use SpringDevs\Subscription\Illuminate\Helper; |
| 20 |
|
| 21 |
if ( ! isset( $id ) ) { |
| 22 |
return; |
| 23 |
} |
| 24 |
|
| 25 |
if ( ! get_the_title( $id ) ) { |
| 26 |
return; |
| 27 |
} |
| 28 |
|
| 29 |
do_action( 'before_single_subscrpt_content' ); |
| 30 |
?> |
| 31 |
<style> |
| 32 |
.auto-renew-on, |
| 33 |
.subscription_renewal_early, |
| 34 |
.auto-renew-off { |
| 35 |
margin-bottom: 10px; |
| 36 |
} |
| 37 |
.subscrpt_action_buttons { |
| 38 |
display: flex; |
| 39 |
flex-wrap: wrap; |
| 40 |
gap: 10px; |
| 41 |
} |
| 42 |
</style> |
| 43 |
<table class="woocommerce-table woocommerce-table--order-details shop_table order_details subscription_details"> |
| 44 |
<tbody> |
| 45 |
<tr> |
| 46 |
<td><?php esc_html_e( 'Order', 'sdevs_subscrpt' ); ?></td> |
| 47 |
<td><a href="<?php echo esc_html( wc_get_endpoint_url( 'view-order', $order->get_id(), wc_get_page_permalink( 'myaccount' ) ) ); ?>" target="_blank"># <?php echo esc_html( $order->get_id() ); ?></a></td> |
| 48 |
</tr> |
| 49 |
<tr> |
| 50 |
<td><?php esc_html_e( 'Status', 'sdevs_subscrpt' ); ?></td> |
| 51 |
<td><span class="subscrpt-<?php echo esc_html( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></span></td> |
| 52 |
</tr> |
| 53 |
<?php if ( null != $trial && 'off' !== $trial ) : ?> |
| 54 |
<tr> |
| 55 |
<td><?php esc_html_e( 'Trial', 'sdevs_subscrpt' ); ?></td> |
| 56 |
<td><?php echo esc_html( $trial ); ?></td> |
| 57 |
</tr> |
| 58 |
<?php endif; ?> |
| 59 |
<tr> |
| 60 |
<td><?php esc_html_e( ( 'null' == $trial || 'off' === $trial_mode ? 'Start date' : ( 'extended' === $trial_mode ? 'Trial End & Subscription Start' : 'Trial End & First Billing' ) ), 'sdevs_subscrpt' ); ?></td> |
| 61 |
<td><?php echo esc_html( ! empty( $start_date ) ? gmdate( 'F d, Y', $start_date ) : '-' ); ?></td> |
| 62 |
</tr> |
| 63 |
<?php if ( null == $trial || in_array( $trial_mode, array( 'off', 'extended' ), true ) ) : ?> |
| 64 |
<tr> |
| 65 |
<td> |
| 66 |
<?php |
| 67 |
esc_html_e( 'Next payment date', 'sdevs_subscrpt' ); |
| 68 |
?> |
| 69 |
</td> |
| 70 |
<td> |
| 71 |
<?php echo esc_html( ! empty( $next_date ) ? gmdate( 'F d, Y', $next_date ) : '-' ); ?> |
| 72 |
</td> |
| 73 |
</tr> |
| 74 |
<?php endif; ?> |
| 75 |
<?php if ( ! empty( $order->get_payment_method_title() ) ) : ?> |
| 76 |
<tr> |
| 77 |
<td><?php esc_html_e( 'Payment', 'sdevs_subscrpt' ); ?></td> |
| 78 |
<td> |
| 79 |
<span data-is_manual="yes" class="subscription-payment-method"><?php echo esc_html( $order->get_payment_method_title() ); ?></span> |
| 80 |
</td> |
| 81 |
</tr> |
| 82 |
<?php endif; ?> |
| 83 |
<?php if ( 0 < count( $action_buttons ) ) : ?> |
| 84 |
<tr> |
| 85 |
<td><?php echo esc_html_e( 'Actions', 'sdevs_subscrpt' ); ?></td> |
| 86 |
<td class="subscrpt_action_buttons"> |
| 87 |
<?php foreach ( $action_buttons as $action_button ) : ?> |
| 88 |
<a href="<?php echo esc_attr( $action_button['url'] ); ?>" class="button |
| 89 |
<?php |
| 90 |
if ( isset( $action_button['class'] ) ) { |
| 91 |
echo esc_attr( $action_button['class'] );} |
| 92 |
?> |
| 93 |
<?php echo esc_attr( $wp_button_class ); ?>"><?php echo esc_html( $action_button['label'] ); ?></a> |
| 94 |
<?php endforeach; ?> |
| 95 |
</td> |
| 96 |
</tr> |
| 97 |
<?php endif; ?> |
| 98 |
</tbody> |
| 99 |
</table> |
| 100 |
|
| 101 |
<?php do_action( 'subscrpt_before_subscription_totals', (int) $id ); ?> |
| 102 |
|
| 103 |
<h2><?php echo esc_html_e( 'Subscription totals', 'sdevs_subscrpt' ); ?></h2> |
| 104 |
<table class="woocommerce-table woocommerce-table--order-details shop_table order_details"> |
| 105 |
<thead> |
| 106 |
<tr> |
| 107 |
<th class="product-name"><?php echo esc_html_e( 'Product', 'sdevs_subscrpt' ); ?></th> |
| 108 |
<th class="product-total"><?php echo esc_html_e( 'Total', 'sdevs_subscrpt' ); ?></th> |
| 109 |
</tr> |
| 110 |
</thead> |
| 111 |
<tbody> |
| 112 |
<?php |
| 113 |
$product_name = $order_item->get_name(); |
| 114 |
$product_link = get_permalink( $order_item->get_variation_id() !== 0 ? $order_item->get_variation_id() : $order_item->get_product_id() ); |
| 115 |
$order_item_meta = $order_item->get_meta( '_subscrpt_meta', true ); |
| 116 |
$time = '1' === $order_item_meta['time'] ? null : $order_item_meta['time']; |
| 117 |
$type = subscrpt_get_typos( $order_item_meta['time'], $order_item_meta['type'] ); |
| 118 |
$product_price_html = Helper::format_price_with_order_item( get_post_meta( $id, '_subscrpt_price', true ), $order_item->get_id() ); |
| 119 |
?> |
| 120 |
<tr class="order_item"> |
| 121 |
<td class="product-name"> |
| 122 |
<a href="<?php echo esc_html( $product_link ); ?>"><?php echo esc_html( $product_name ); ?></a> |
| 123 |
<strong class="product-quantity">× <?php echo esc_html( $order_item->get_quantity() ); ?></strong> |
| 124 |
</td> |
| 125 |
<td class="product-total"> |
| 126 |
<span class="woocommerce-Price-amount amount"> |
| 127 |
<?php |
| 128 |
echo wp_kses_post( Helper::format_price_with_order_item( get_post_meta( $id, '_subscrpt_price', true ), $order_item->get_id() ) ); |
| 129 |
?> |
| 130 |
</span> |
| 131 |
</td> |
| 132 |
</tr> |
| 133 |
</tbody> |
| 134 |
<tfoot> |
| 135 |
<tr> |
| 136 |
<th scope="row"><?php esc_html_e( 'Subtotal', 'sdevs_subscrpt' ); ?>:</th> |
| 137 |
<td> |
| 138 |
<span class="woocommerce-Price-amount amount"><?php echo wp_kses_post( wc_price( get_post_meta( $id, '_subscrpt_price', true ), array( 'currency' => $order->get_currency() ) ) ); ?></span> |
| 139 |
</td> |
| 140 |
</tr> |
| 141 |
<tr> |
| 142 |
<th scope="row"><?php esc_html_e( 'Renew', 'sdevs_subscrpt' ); ?>:</th> |
| 143 |
<td> |
| 144 |
<span class="woocommerce-Price-amount amount"> |
| 145 |
<?php echo wp_kses_post( $product_price_html ); ?> |
| 146 |
</span> |
| 147 |
</td> |
| 148 |
</tr> |
| 149 |
</tfoot> |
| 150 |
</table> |
| 151 |
|
| 152 |
<section class="woocommerce-customer-details"> |
| 153 |
<h2 class="woocommerce-column__title"><?php esc_html_e( 'Billing address', 'sdevs_subscrpt' ); ?></h2> |
| 154 |
<address> |
| 155 |
<?php echo wp_kses_post( $order->get_formatted_billing_address() ); ?> |
| 156 |
<p class="woocommerce-customer-details--phone"><?php echo esc_html( $order->get_billing_phone() ); ?></p> |
| 157 |
<p class="woocommerce-customer-details--email"><?php echo esc_html( $order->get_billing_email() ); ?></p> |
| 158 |
</address> |
| 159 |
</section> |
| 160 |
<div class="clear"></div> |
| 161 |
|