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