| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying email order items table. |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/learnpress/emails/order-items-table.php |
| 6 |
* |
| 7 |
* @author ThimPress |
| 8 |
* @package LearnPress/Templates |
| 9 |
* @version 3.0.1 |
| 10 |
* @editor tungnx |
| 11 |
* @modify 4.1.3 |
| 12 |
*/ |
| 13 |
|
| 14 |
/** |
| 15 |
* Prevent loading this file directly |
| 16 |
*/ |
| 17 |
defined( 'ABSPATH' ) || exit(); |
| 18 |
/** |
| 19 |
* @var $order LP_Order |
| 20 |
*/ |
| 21 |
if ( ! isset( $order ) ) { |
| 22 |
error_log( 'Invalid params on ' . __FILE__ ); |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
$items = $order->get_items(); |
| 27 |
|
| 28 |
if ( ! $items ) { |
| 29 |
return; |
| 30 |
} |
| 31 |
|
| 32 |
$email_content = ''; |
| 33 |
|
| 34 |
if ( $order->is_manual() ) { |
| 35 |
$user_ids = $order->get_user_id(); |
| 36 |
if ( is_array( $user_ids ) ) { |
| 37 |
$email_arr = []; |
| 38 |
foreach ( $user_ids as $user_id ) { |
| 39 |
$user = get_user_by( 'ID', $user_id ); |
| 40 |
if ( $user ) { |
| 41 |
$email_arr[] = $user->user_email; |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
$email_content = implode( ',', $email_arr ); |
| 46 |
} else { |
| 47 |
$email_content = $order->get_user_email( $user_ids ); |
| 48 |
} |
| 49 |
} else { |
| 50 |
$email_content = $order->get_user_email( $order->get_user_id() ); |
| 51 |
} |
| 52 |
?> |
| 53 |
|
| 54 |
<h3 class="order-table-items-heading"> |
| 55 |
<?php _e( 'Order summary', 'learnpress' ); ?> |
| 56 |
</h3> |
| 57 |
|
| 58 |
<table class="order-details"> |
| 59 |
<tr> |
| 60 |
<th><?php _e( 'Order Number', 'learnpress' ); ?></th> |
| 61 |
<td><?php echo esc_html( $order->get_order_number() ); ?></td> |
| 62 |
</tr> |
| 63 |
<tr> |
| 64 |
<th><?php _e( 'Purchase Date', 'learnpress' ); ?></th> |
| 65 |
<td><?php echo date_i18n( get_option( 'date_format' ), $order->get_order_date( 'timestamp' ) ); ?></td> |
| 66 |
</tr> |
| 67 |
<tr> |
| 68 |
<th><?php _e( 'Payment Method', 'learnpress' ); ?></th> |
| 69 |
<td><?php echo wp_kses_post( $order->get_payment_method_title() ); ?></td> |
| 70 |
</tr> |
| 71 |
<tr> |
| 72 |
<th><?php _e( 'Status', 'learnpress' ); ?></th> |
| 73 |
<td><?php echo wp_kses_post( $order->get_order_status_html() ); ?></td> |
| 74 |
</tr> |
| 75 |
<tr> |
| 76 |
<th><?php _e( 'User Email', 'learnpress' ); ?></th> |
| 77 |
<td><?php echo wp_kses_post( $email_content ); ?></td> |
| 78 |
</tr> |
| 79 |
</table> |
| 80 |
|
| 81 |
<table class="order-table-items" cellspacing="0" cellpadding="5"> |
| 82 |
<thead> |
| 83 |
<tr> |
| 84 |
<?php do_action( 'learn-press/before-email-order-item-heading', $order ); ?> |
| 85 |
<th class="column-name"><?php _e( 'Course', 'learnpress' ); ?></th> |
| 86 |
<th class="column-quantity"><?php _e( 'Quantity', 'learnpress' ); ?></th> |
| 87 |
<th class="column-number"><?php _e( 'Price', 'learnpress' ); ?></th> |
| 88 |
<?php do_action( 'learn-press/after-email-order-item-heading', $order ); ?> |
| 89 |
</tr> |
| 90 |
</thead> |
| 91 |
<tbody> |
| 92 |
<?php |
| 93 |
foreach ( $items as $item_id => $item ) : |
| 94 |
if ( ! isset( $item['course_id'] ) ) { |
| 95 |
continue; |
| 96 |
} |
| 97 |
$course = apply_filters( 'learn-press/email-order-item-course', learn_press_get_course( $item['course_id'] ), $item ); |
| 98 |
|
| 99 |
?> |
| 100 |
<tr> |
| 101 |
<?php do_action( 'learn-press/before-email-order-item', $item_id, $item, $order ); ?> |
| 102 |
<td class="column-name"> |
| 103 |
<?php echo apply_filters( 'learn-press/email-order-item-name', $item['name'], $item ); ?> |
| 104 |
</td> |
| 105 |
<td class="column-quantity"> |
| 106 |
<?php echo apply_filters( 'learn-press/email-order-item-quantity', $item['quantity'], $item ); ?> |
| 107 |
</td> |
| 108 |
<td class="column-number"> |
| 109 |
<?php echo apply_filters( 'learn-press/email-order-item-cost', learn_press_format_price( $item['total'], learn_press_get_currency_symbol( $order->get_currency() ) ), $item ); ?> |
| 110 |
</td> |
| 111 |
<?php do_action( 'learn-press/after-email-order-item', $item_id, $item, $order ); ?> |
| 112 |
</tr> |
| 113 |
|
| 114 |
<?php endforeach; ?> |
| 115 |
</tbody> |
| 116 |
<tfoot> |
| 117 |
<tr> |
| 118 |
<td colspan="2" class="column-number"><?php _e( 'Total', 'learnpress' ); ?></td> |
| 119 |
<td class="column-number"> |
| 120 |
<?php echo esc_html( $order->get_formatted_order_total() ); ?> |
| 121 |
</td> |
| 122 |
</tr> |
| 123 |
</tfoot> |
| 124 |
</table> |
| 125 |
|