| 1 |
<?php |
| 2 |
/** |
| 3 |
* Related subscriptions for email. |
| 4 |
* |
| 5 |
* @var \WC_Order $order Order Object. |
| 6 |
* @var object[] $histories Order Object. |
| 7 |
* |
| 8 |
* @package SpringDevs\Subscription\Illuminate\Email |
| 9 |
*/ |
| 10 |
|
| 11 |
// Exit if accessed directly. |
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
$subscrpt_th_style = 'width:40%;padding:10px 14px;text-align:left;vertical-align:top;font-weight:600;color:#50575e;background-color:#f6f7f7;'; |
| 17 |
$subscrpt_td_style = 'padding:10px 14px;text-align:left;vertical-align:top;color:#1d2327;'; |
| 18 |
$subscrpt_divider = 'border-top:1px solid #e3e3e8;'; |
| 19 |
?> |
| 20 |
|
| 21 |
<div style="margin-bottom:40px;"> |
| 22 |
<h2 style="margin:0 0 8px;"><?php esc_html_e( 'Related Subscriptions', 'subscription' ); ?></h2> |
| 23 |
|
| 24 |
<?php if ( ! $order->has_status( 'completed' ) ) : ?> |
| 25 |
<p style="margin:0 0 16px;"><small><?php esc_html_e( 'Your subscription will be activated when order status is completed.', 'subscription' ); ?></small></p> |
| 26 |
<?php endif; ?> |
| 27 |
|
| 28 |
<?php |
| 29 |
foreach ( $histories as $history ) : |
| 30 |
$item = $order->get_item( $history->order_item_id ); |
| 31 |
|
| 32 |
// Skip if item is not found. |
| 33 |
if ( ! $item ) { |
| 34 |
continue; |
| 35 |
} |
| 36 |
|
| 37 |
$item_meta = wc_get_order_item_meta( $history->order_item_id, '_subscrpt_meta', true ); |
| 38 |
$subscription_id = $history->subscription_id; |
| 39 |
$subscription_status_object = get_post_status_object( get_post_status( $subscription_id ) ); |
| 40 |
$has_trial = isset( $item_meta['trial'] ) && strlen( $item_meta['trial'] ) > 2; |
| 41 |
$start_date = get_post_meta( $subscription_id, '_subscrpt_start_date', true ); |
| 42 |
?> |
| 43 |
<div style="margin-bottom:24px;"> |
| 44 |
<p style="margin:0 0 6px;font-weight:600;color:#1d2327;"><?php echo wp_kses_post( get_the_title( $subscription_id ) ); ?></p> |
| 45 |
|
| 46 |
<table cellspacing="0" cellpadding="0" border="0" style="width:100%;border-collapse:separate;border-spacing:0;border:1px solid #e3e3e8;border-radius:6px;overflow:hidden;font-family:'Helvetica Neue',Helvetica,Roboto,Arial,sans-serif;font-size:14px;"> |
| 47 |
<tbody> |
| 48 |
<tr> |
| 49 |
<th scope="row" style="<?php echo esc_attr( $subscrpt_th_style ); ?>"><?php esc_html_e( 'Item', 'subscription' ); ?></th> |
| 50 |
<td style="<?php echo esc_attr( $subscrpt_td_style ); ?>"> |
| 51 |
<a href="<?php echo esc_url( get_permalink( $item->get_product_id() ) ); ?>" style="color:#7f54b3;"><?php echo wp_kses_post( $item->get_name() ); ?></a> |
| 52 |
<strong class="product-quantity">× <?php echo esc_html( $item->get_quantity() ); ?></strong> |
| 53 |
</td> |
| 54 |
</tr> |
| 55 |
<tr> |
| 56 |
<th scope="row" style="<?php echo esc_attr( $subscrpt_th_style . $subscrpt_divider ); ?>"><?php esc_html_e( 'Status', 'subscription' ); ?></th> |
| 57 |
<td style="<?php echo esc_attr( $subscrpt_td_style . $subscrpt_divider ); ?>"><?php echo esc_html( $subscription_status_object->label ); ?></td> |
| 58 |
</tr> |
| 59 |
<tr> |
| 60 |
<th scope="row" style="<?php echo esc_attr( $subscrpt_th_style . $subscrpt_divider ); ?>"><?php esc_html_e( 'Recurring amount', 'subscription' ); ?></th> |
| 61 |
<td style="<?php echo esc_attr( $subscrpt_td_style . $subscrpt_divider ); ?>"> |
| 62 |
<?php |
| 63 |
// Strikes the original amount when a discount carries into renewals. |
| 64 |
echo wp_kses_post( |
| 65 |
SpringDevs\Subscription\Illuminate\Helper::get_subscription_recurring_price_html( |
| 66 |
$subscription_id, |
| 67 |
$item, |
| 68 |
[ 'del_style' => 'color: #999999;' ] |
| 69 |
) |
| 70 |
); |
| 71 |
?> |
| 72 |
</td> |
| 73 |
</tr> |
| 74 |
<?php if ( $has_trial ) : ?> |
| 75 |
<tr> |
| 76 |
<th scope="row" style="<?php echo esc_attr( $subscrpt_th_style . $subscrpt_divider ); ?>"><?php esc_html_e( 'Trial', 'subscription' ); ?></th> |
| 77 |
<td style="<?php echo esc_attr( $subscrpt_td_style . $subscrpt_divider ); ?>"><?php echo esc_html( $item_meta['trial'] ); ?></td> |
| 78 |
</tr> |
| 79 |
<tr> |
| 80 |
<th scope="row" style="<?php echo esc_attr( $subscrpt_th_style . $subscrpt_divider ); ?>"><?php esc_html_e( 'First billing on', 'subscription' ); ?></th> |
| 81 |
<td style="<?php echo esc_attr( $subscrpt_td_style . $subscrpt_divider ); ?>"><?php echo ! empty( $start_date ) ? esc_html( wp_date( 'F d, Y', $start_date ) ) : '-'; ?></td> |
| 82 |
</tr> |
| 83 |
<?php endif; ?> |
| 84 |
</tbody> |
| 85 |
</table> |
| 86 |
</div> |
| 87 |
<?php |
| 88 |
endforeach; |
| 89 |
?> |
| 90 |
</div> |
| 91 |
|