PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 3.2.2
Tutor LMS – eLearning and online course solution v3.2.2
3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.11 1.2.12 1.2.13 1.2.20 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / ecommerce / EmailController.php
tutor / ecommerce Last commit date
PaymentGateways 1 year ago AdminMenu.php 1 year ago BillingController.php 1 year ago CartController.php 1 year ago CheckoutController.php 1 year ago CouponController.php 1 year ago Ecommerce.php 1 year ago EmailController.php 1 year ago HooksHandler.php 1 year ago OptionKeys.php 1 year ago OrderActivitiesController.php 1 year ago OrderController.php 1 year ago PaymentHandler.php 1 year ago Settings.php 1 year ago Tax.php 1 year ago currency.php 1 year ago
EmailController.php
689 lines
1 <?php
2 /**
3 * Manage Email
4 *
5 * @package Tutor\Ecommerce
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 3.0.0
9 */
10
11 namespace Tutor\Ecommerce;
12
13 use Tutor\Models\OrderModel;
14 use TutorPro\Subscription\Models\PlanModel;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * EmailController class
22 *
23 * @since 3.0.0
24 */
25 class EmailController {
26 const INACTIVE_REMINDED_META = 'tutor_inactive_reminded';
27 const TO_STUDENTS = 'email_to_students';
28 const TO_TEACHERS = 'email_to_teachers';
29 const TO_ADMIN = 'email_to_admin';
30 const ORDER_EMAILS = 'order_emails';
31
32 /**
33 * Queue table
34 *
35 * @var string
36 */
37 private $queue_table;
38
39 /**
40 * Constructor.
41 *
42 * Initializes the Orders class, sets the page title, and optionally registers
43 * hooks for handling AJAX requests related to order data, bulk actions, order status updates,
44 * and order deletions.
45 *
46 * @param bool $register_hooks Whether to register hooks for handling requests. Default is true.
47 *
48 * @since 3.0.0
49 *
50 * @return void
51 */
52 public function __construct( $register_hooks = true ) {
53 global $wpdb;
54 $this->queue_table = $wpdb->tutor_email_queue;
55
56 if ( ! $register_hooks ) {
57 return;
58 }
59
60 add_action( 'wp_ajax_tutor_send_mail_test', array( $this, 'send_test_mail' ) );
61 add_action( 'tutor_order_placed', array( $this, 'order_placed' ) );
62 add_action( 'tutor_order_payment_status_changed', array( $this, 'order_updated' ), 10, 4 );
63
64 add_filter( 'tutor_pro/email/list', array( $this, 'setup_email_config' ) );
65 }
66
67 // @TODO: Will be removed later.
68 public function send_test_mail() {
69 $this->order_placed( get_current_user_id() );
70 }
71
72 /**
73 * Send E-Mail Notification for Tutor Event.
74 *
75 * @param string $to to address.
76 * @param string $subject email subject.
77 * @param string $message message.
78 * @param mixed $headers headers.
79 * @param array $attachments attachments.
80 * @param bool $force_enqueue force enqueue.
81 * @param int $batch batch number, default false.
82 *
83 * @return void
84 */
85 public function send( $to, $subject, $message, $headers, $attachments = array(), $force_enqueue = false, $batch = false ) {
86 $message = apply_filters( 'tutor_mail_content', $message );
87 $this->enqueue_email( $to, $subject, $message, $headers, $attachments, $force_enqueue, $batch );
88 }
89
90 /**
91 * Email enqueue.
92 *
93 * @param string $to to.
94 * @param string $subject subject.
95 * @param string $message message.
96 * @param mixed $headers headers.
97 * @param array $attachments attachments.
98 * @param boolean $force_enqueue force enqueue.
99 * @param int $batch batch number. default false.
100 *
101 * @return void
102 */
103 private function enqueue_email( $to, $subject, $message, $headers, $attachments = array(), $force_enqueue = false, $batch = false ) {
104 global $wpdb;
105
106 if ( ! $batch ) {
107 $batch = time();
108 }
109
110 $data = array(
111 'mail_to' => $to,
112 'subject' => $subject,
113 'message' => $message,
114 'headers' => serialize( $headers ),
115 'batch' => $batch,
116 );
117
118 if ( is_string( $to ) && ! $force_enqueue ) {
119 // Send email instantly in case single recipient.
120 $this->send_mail( array( $data ) );
121 return;
122 }
123
124 ! is_array( $to ) ? $to = array( $to ) : 0;
125
126 foreach ( $to as $email ) {
127 $insert_data = array_merge( $data, array( 'mail_to' => $email ) );
128 $wpdb->insert( $this->queue_table, $insert_data );
129 }
130 }
131
132 /**
133 * Sent email.
134 *
135 * @param array $mails list of mail address.
136 *
137 * @return void
138 */
139 public function send_mail( $mails ) {
140 add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
141 add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
142 add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
143
144 foreach ( $mails as $mail ) {
145 $mail['headers'] = unserialize( $mail['headers'] );
146 wp_mail( $mail['mail_to'], $mail['subject'], $mail['message'], $mail['headers'] );
147 }
148
149 remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
150 remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
151 remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
152 }
153
154 /**
155 * Load email template.
156 *
157 * @param string $template template.
158 * @param boolean $pro is pro.
159 * @param array $extra extra data.
160 *
161 * @return void
162 */
163 public function tutor_load_email_template( $template, $extra = array() ) {
164 extract( $extra ); //phpcs:ignore
165 include tutor_get_template( 'email.' . $template, );
166 }
167
168 /**
169 * Get the from name for outgoing emails from tutor
170 *
171 * @return string
172 */
173 public function get_from_name() {
174 $email_from_name = tutor_utils()->get_option( 'email_from_name' );
175 $from_name = apply_filters( 'tutor_email_from_name', $email_from_name );
176 return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
177 }
178
179 /**
180 * Get the from name for outgoing emails from tutor
181 *
182 * @return string
183 */
184 public function get_from_address() {
185 $email_from_address = tutor_utils()->get_option( 'email_from_address' );
186 $from_address = apply_filters( 'tutor_email_from_address', $email_from_address );
187 return sanitize_email( $from_address );
188 }
189
190 /**
191 * Get content type
192 *
193 * @return string
194 */
195 public function get_content_type() {
196 return apply_filters( 'tutor_email_content_type', 'text/html' );
197 }
198
199 /**
200 * Get message.
201 *
202 * @param string $message message.
203 * @param array $search search.
204 * @param array $replace replace.
205 *
206 * @return string
207 */
208 public function get_message( $message = '', $search = array(), $replace = array() ) {
209 $email_footer_text = tutor_utils()->get_option( 'email_footer_text' );
210
211 $placeholders = array(
212 '{site_name}' => get_bloginfo( 'name' ),
213 '{site_url}' => site_url(),
214 '{current_year}' => gmdate( 'Y' ),
215 );
216
217 $email_footer_text = str_replace( array_keys( $placeholders ), array_values( $placeholders ), $email_footer_text );
218 $message = str_replace( $search, $replace, $message );
219 if ( $email_footer_text ) {
220 $message .= '<div class="tutor-email-footer-content">' . wp_unslash( json_decode( $email_footer_text ) ) . '</div>';
221 }
222 return $message;
223 }
224
225 /**
226 * Ready the e-mail message
227 * Used unslash and trim (") from front and end of the message
228 *
229 * @param string $message message.
230 * @return string
231 */
232 public function prepare_message( $message ) {
233 return wp_unslash( json_decode( $message ) );
234 }
235
236 /**
237 * Function to replace and return
238 *
239 * @since 2.6.1
240 *
241 * Conditionally replacing message to avoid deprecation error what
242 * was added on the PHP 8 version
243 *
244 * @param mixed $message message.
245 * @param mixed $search search.
246 * @param mixed $replace replace.
247 *
248 * @return string
249 */
250 public function get_replaced_text( $message = '', $search = array(), $replace = array() ) {
251 return $message ? str_replace( $search, $replace, $message ) : $message;
252 }
253
254 /**
255 * Get trigger saved data with fallback default data support.
256 *
257 * @since 2.5.0
258 *
259 * @param string $to_key to key like email_to_students, email_to_teachers, email_to_admin.
260 * @param string $trigger_key trigger name.
261 *
262 * @return array
263 */
264 public function get_option_data( $to_key, $trigger_key ) {
265 $email_data = get_option( 'email_template_data' );
266 $default_data = $this->get_email_data();
267
268 return isset( $email_data[ $to_key ][ $trigger_key ] ) ? $email_data[ $to_key ][ $trigger_key ] : $default_data[ $to_key ][ $trigger_key ];
269 }
270
271 /**
272 * Send mail once new order place
273 *
274 * @since 3.0.0
275 *
276 * @param array $order_data Order data.
277 *
278 * @return void
279 */
280 public function order_placed( array $order_data ) {
281
282 $order_data = (object) $order_data;
283 $order_data->items = (object) $order_data->items;
284
285 $student_ids = array( $order_data->user_id );
286 $admin_ids = array();
287 $instructor_ids = array();
288
289 // Set admin user ids.
290 $admin_users = get_users( array( 'role' => 'administrator' ) );
291
292 foreach ( $admin_users as $admin_user ) {
293 $admin_ids[] = $admin_user->ID;
294 }
295
296 // Set instructor ids.
297 foreach ( $order_data->items as $item ) {
298 $item = (object) $item;
299 $course_id = $item->item_id;
300 if ( OrderModel::TYPE_SUBSCRIPTION === $order_data->order_type || OrderModel::TYPE_RENEWAL === $order_data->order_type ) {
301 $course_id = apply_filters( 'tutor_subscription_course_by_plan', $course_id, $order_data );
302 }
303 $instructor_ids[] = get_post_field( 'post_author', $course_id );
304 }
305
306 if ( tutor()->has_pro ) {
307 if ( tutor_utils()->get_option( self::TO_STUDENTS . '.new_order' ) ) {
308 $this->send_email_to( self::TO_STUDENTS, 'new_order', $student_ids, $order_data->id );
309 }
310
311 if ( tutor_utils()->get_option( self::TO_ADMIN . '.new_order' ) ) {
312 $this->send_email_to( self::TO_ADMIN, 'new_order', $admin_ids, $order_data->id );
313 }
314
315 if ( tutor_utils()->get_option( self::TO_TEACHERS . '.new_order' ) ) {
316 $this->send_email_to( self::TO_TEACHERS, 'new_order', $instructor_ids, $order_data->id );
317 }
318 } else {
319 $this->send_email_to( self::TO_STUDENTS, 'new_order', $student_ids, $order_data->id );
320 $this->send_email_to( self::TO_ADMIN, 'new_order', $admin_ids, $order_data->id );
321 $this->send_email_to( self::TO_TEACHERS, 'new_order', $instructor_ids, $order_data->id );
322 }
323 }
324
325 /**
326 * Send mail once new order place
327 *
328 * @since 3.0.0
329 *
330 * @param int $order_id Order id.
331 * @param string $prev_payment_status Order previous payment status.
332 * @param string $new_payment_status Order new status.
333 *
334 * @return void
335 */
336 public function order_updated( $order_id, $prev_payment_status, $new_payment_status ) {
337
338 $order_data = ( new OrderModel() )->get_order_by_id( $order_id );
339
340 if ( OrderModel::PAYMENT_PARTIALLY_REFUNDED === $new_payment_status || ( OrderModel::PAYMENT_REFUNDED === $new_payment_status && OrderModel::ORDER_COMPLETED === $order_data->order_status ) ) {
341 return;
342 }
343
344 $student_ids = array( $order_data->user_id );
345 $admin_ids = array();
346 $instructor_ids = array();
347
348 // Set admin user ids.
349 $admin_users = get_users( array( 'role' => 'administrator' ) );
350
351 foreach ( $admin_users as $admin_user ) {
352 $admin_ids[] = $admin_user->ID;
353 }
354
355 // Set instructor ids.
356 foreach ( $order_data->items as $item ) {
357 $course_id = $item->id;
358 if ( OrderModel::TYPE_SUBSCRIPTION === $order_data->order_type || OrderModel::TYPE_RENEWAL === $order_data->order_type ) {
359 $course_id = apply_filters( 'tutor_subscription_course_by_plan', $course_id, $order_data );
360 }
361 $instructor_ids[] = get_post_field( 'post_author', $course_id );
362 }
363
364 if ( tutor_utils()->get_option( self::TO_STUDENTS . '.order_status_updated' ) ) {
365 $this->send_email_to( self::TO_STUDENTS, 'order_status_updated', $student_ids, $order_data->id );
366 }
367
368 if ( tutor_utils()->get_option( self::TO_ADMIN . '.order_status_updated' ) ) {
369 $this->send_email_to( self::TO_TEACHERS, 'order_status_updated', $instructor_ids, $order_data->id );
370 }
371
372 if ( tutor_utils()->get_option( self::TO_TEACHERS . '.order_status_updated' ) ) {
373 $this->send_email_to( self::TO_ADMIN, 'order_status_updated', $admin_ids, $order_data->id );
374 }
375 }
376
377 /**
378 * Send email to a specific recipient
379 *
380 * @since 3.0.0
381 *
382 * @param string $recipient_type Recipient type like
383 * email_to_students, email_to_teachers, email_to_admin.
384 * @param string $email_type New order/ order status updated.
385 * @param array $recipients Recipients ids.
386 * @param int $order_id Order id.
387 *
388 * @return void
389 */
390 private function send_email_to( $recipient_type, $email_type, $recipients, $order_id ) {
391 $site_url = get_bloginfo( 'url' );
392 $site_name = get_bloginfo( 'name' );
393 $option_data = $this->get_option_data( $recipient_type, $email_type );
394
395 $order_data = ( new OrderModel() )->get_order_by_id( $order_id );
396 $recipients = array_unique( $recipients );
397 foreach ( $recipients as $recipient ) {
398 // Ignore email when teachers himself admin.
399 // because admin email has already been send.
400 if ( 'email_to_teachers' === $recipient_type && user_can( $recipient, 'manage_options' ) ) {
401 continue;
402 }
403
404 /**
405 * Notification preference check for student.
406 *
407 * @since 3.1.0
408 */
409 if ( self::TO_STUDENTS === $recipient_type ) {
410 $trigger_name = $email_type;
411 $user_id = $recipient;
412
413 $notification_enabled = apply_filters( 'tutor_is_notification_enabled_for_user', true, 'email', self::TO_STUDENTS, $trigger_name, $user_id );
414 if ( ! $notification_enabled ) {
415 continue;
416 }
417 }
418
419 $user_data = get_userdata( $recipient );
420 $header = 'Content-Type: ' . $this->get_content_type() . "\r\n";
421 $header = apply_filters( 'new_order_email_header', $header );
422
423 $replacable['{testing_email_notice}'] = '';
424 $replacable['{user_name}'] = tutor_utils()->get_user_name( $user_data );
425 $replacable['{site_url}'] = $site_url;
426 $replacable['{site_name}'] = $site_name;
427
428 if ( OrderModel::TYPE_SUBSCRIPTION === $order_data->order_type ) {
429 $plan = ( new PlanModel() )->get_plan( $order_data->items[0]->id );
430 $replacable['{course_name}'] = $plan->plan_name;
431 } else {
432 $replacable['{course_name}'] = count( $order_data->items ) > 1 ? _n( 'Course', 'Courses', count( $order_data->items ) ) : $order_data->items[0]->title;
433 }
434
435 $replacable['{admin_order_url}'] = admin_url( 'admin.php?page=tutor_orders&action=edit&id=' . $order_id );
436
437 $replacable['{site_order_url}'] = 'email_to_students' === $recipient_type ? tutor_utils()->get_tutor_dashboard_page_permalink( 'purchase_history' ) : tutor_utils()->get_tutor_dashboard_page_permalink( 'analytics/statements' );
438
439 $replacable['{order_id}'] = '#' . $order_data->id;
440 $replacable['{order_date}'] = tutor_i18n_get_formated_date( $order_data->created_at_gmt, get_option( 'date_format' ) );
441 $replacable['{order_total}'] = tutor_get_formatted_price( $order_data->total_price );
442 $replacable['{order_status}'] = ucfirst( $order_data->order_status );
443 $replacable['{order_payment_status}'] = ucfirst( $order_data->payment_status );
444
445 $student = get_userdata( $order_data->student->id );
446 if ( is_a( $student, 'WP_User' ) ) {
447 $replacable['{student_name}'] = $student->display_name;
448 }
449
450 $replacable['{dashboard_url}'] = tutor_utils()->get_tutor_dashboard_page_permalink();
451 $replacable['{logo}'] = isset( $option_data['logo'] ) ? $option_data['logo'] : '';
452 $replacable['{email_heading}'] = $this->get_replaced_text( $option_data['heading'], array_keys( $replacable ), array_values( $replacable ) );
453
454 $replacable['{email_message}'] = $this->get_replaced_text( $this->prepare_message( $option_data['message'] ), array_keys( $replacable ), array_values( $replacable ) );
455
456 $replacable['{footer_text}'] = $this->get_replaced_text( $option_data['footer_text'] ?? '', array_keys( $replacable ), array_values( $replacable ) );
457
458 $subject = $this->get_replaced_text( $option_data['subject'], array_keys( $replacable ), array_values( $replacable ) );
459
460 ob_start();
461 $this->tutor_load_email_template( 'order_new_' . $recipient_type );
462 $email_tpl = apply_filters( 'tutor_email_tpl_' . $recipient_type, ob_get_clean() );
463 $message = html_entity_decode( $this->get_message( $email_tpl, array_keys( $replacable ), array_values( $replacable ) ) );
464
465 $enable_queue = tutor()->has_pro && tutor_utils()->get_option( 'tutor_email_disable_wpcron' );
466
467 $this->send( $user_data->user_email, $subject, $message, $header, array(), $enable_queue );
468 }
469 }
470
471 /**
472 * Setup email data
473 *
474 * @since 3.0.0
475 *
476 * @param array $email_config Default email config data.
477 *
478 * @return array.
479 */
480 public function setup_email_config( $email_config ) {
481 $order_email = $this->get_email_data();
482
483 $email_config[ self::TO_STUDENTS ]['new_order'] = $order_email[ self::TO_STUDENTS ]['new_order'];
484 $email_config[ self::TO_STUDENTS ]['order_status_updated'] = $order_email['email_to_students']['order_status_updated'];
485
486 $email_config[ self::TO_TEACHERS ]['new_order'] = $order_email['email_to_teachers']['new_order'];
487 $email_config[ self::TO_TEACHERS ]['order_status_updated'] = $order_email['email_to_teachers']['order_status_updated'];
488
489 $email_config[ self::TO_ADMIN ]['new_order'] = $order_email['email_to_admin']['new_order'];
490 $email_config[ self::TO_ADMIN ]['order_status_updated'] = $order_email['email_to_admin']['order_status_updated'];
491
492 return $email_config;
493 }
494
495 /**
496 * Get email data.
497 *
498 * @return array
499 */
500 public function get_email_data() {
501 $email_array = array(
502 self::TO_STUDENTS => array(
503 'new_order' => array(
504 'label' => __( 'New order placed', 'tutor' ),
505 'default' => 'on',
506 'template' => 'order_new_' . self::TO_STUDENTS,
507 'tooltip' => __( 'New order emails are sent to chosen recipient(s) when a new order is received.', 'tutor' ),
508 'subject' => __( 'Your order has been received! 🎉', 'tutor' ),
509 'heading' => __( 'Your order has been received!', 'tutor' ),
510 'message' => wp_json_encode(
511 sprintf(
512 '
513 <p>%s {user_name},</p>
514 <p>%s</p>
515 <div>
516 <p>%s</p>
517 <ul>
518 <li>%s {order_id}</li>
519 <li>%s {order_date}</li>
520 <li>%s {order_total}</li>
521 </ul>
522 </div>',
523 esc_html__( 'Hi', 'tutor' ),
524 esc_html__( 'Thank you for your order. We\'ve received your order successfully, and it is now being processed.', 'tutor' ),
525 esc_html__( 'Below are the details of your order:', 'tutor' ),
526 esc_html__( 'Order ID:', 'tutor' ),
527 esc_html__( 'Order Date:', 'tutor' ),
528 esc_html__( 'Total Amount:', 'tutor' )
529 )
530 ),
531 'footer_text' => __( 'We will let you know once your order has been completed and is ready for access.', 'tutor' ),
532 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
533 ),
534 'order_status_updated' => array(
535 'label' => __( 'Order status updated', 'tutor' ),
536 'default' => 'on',
537 'template' => 'order_updated_' . self::TO_STUDENTS,
538 'tooltip' => __( 'Order status update emails are sent to chosen recipient(s) whenever a order status updated.', 'tutor' ),
539 'subject' => __( 'Your Order Status Has Been Updated to {order_status} ', 'tutor' ),
540 'heading' => __( 'Your Order Status Has Been Updated to {order_status}', 'tutor' ),
541 'message' => wp_json_encode(
542 sprintf(
543 '
544 <p>%s</p>
545 <p>%s</p>
546 <ul>
547 <li>%s {order_id}</li>
548 <li>%s {order_status}</li>
549 <li>%s {course_name}</li>
550 <li>%s {order_date}</li>
551 <li>%s {order_total}</li>
552 </ul>',
553 esc_html__( 'Hi {user_name},', 'tutor' ),
554 esc_html__( 'We\'re reaching out to let you know that your order status has been updated to {order_status}. We understand the importance of keeping you informed at every step of the way. Below is a summary of your order:', 'tutor' ),
555 esc_html__( 'Order ID:', 'tutor' ),
556 esc_html__( 'Order Status:', 'tutor' ),
557 esc_html__( 'Course:', 'tutor' ),
558 esc_html__( 'Order Date:', 'tutor' ),
559 esc_html__( 'Total Amount:', 'tutor' )
560 )
561 ),
562 'footer_text' => __( 'We will let you know once your order has been completed and is ready for access.', 'tutor' ),
563 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
564 ),
565 ),
566 self::TO_TEACHERS => array(
567 'new_order' => array(
568 'label' => __( 'New order placed', 'tutor' ),
569 'default' => 'on',
570 'template' => 'order_new_' . self::TO_TEACHERS,
571 'tooltip' => __( 'New order emails are sent to chosen recipient(s) when a new order is received.', 'tutor' ),
572 'subject' => __( 'A New Student Has Enrolled in Your Course! 🎉', 'tutor' ),
573 'heading' => __( 'A New Student Has Enrolled in Your Course!', 'tutor' ),
574 'message' => wp_json_encode(
575 sprintf(
576 '
577 <p>%s {user_name},</p>
578 <p>%s</p>
579 <ul>
580 <li>%s {student_name}</li>
581 <li>%s {order_id}</li>
582 <li>%s {order_date}</li>
583 <li>%s {order_payment_status}</li>
584 </ul>',
585 esc_html__( 'Hi', 'tutor' ),
586 esc_html__( 'We\'re excited to let you know that a new student has just enrolled in one of your courses! Here are the course details:', 'tutor' ),
587 esc_html__( 'Student Name:', 'tutor' ),
588 esc_html__( 'Order ID:', 'tutor' ),
589 esc_html__( 'Order Date:', 'tutor' ),
590 esc_html__( 'Payment Status:', 'tutor' )
591 )
592 ),
593 'footer_text' => __( 'Please review the order and ensure everything is in place for the student\'s access to the course. Thank you.', 'tutor' ),
594 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
595 ),
596 'order_status_updated' => array(
597 'label' => __( 'Order status updated', 'tutor' ),
598 'default' => 'on',
599 'template' => 'order_updated_' . self::TO_TEACHERS,
600 'tooltip' => __( 'Order status update emails are sent to chosen recipient(s) whenever a order status updated.', 'tutor' ),
601 'subject' => __( 'Instructor Notice: Your Student\'s Order Status is Now {order_status}', 'tutor' ),
602 'heading' => __( 'Instructor Notice: Your Student\'s Order Status is Now {order_status}', 'tutor' ),
603 'message' => wp_json_encode(
604 sprintf(
605 '
606 <p>%s</p>
607 <p>%s</p>
608 <ul>
609 <li>%s {order_id}</li>
610 <li>%s {order_status}</li>
611 <li>%s {course_name}</li>
612 <li>%s {order_total}</li>
613 </ul>',
614 esc_html__( 'Hi {user_name},', 'tutor' ),
615 esc_html__( 'We\'d like to update you on your course enrollment status. One of your students has an order that has been updated to {order_status}. Here are the details:', 'tutor' ),
616 esc_html__( 'Order ID:', 'tutor' ),
617 esc_html__( 'Order Status:', 'tutor' ),
618 esc_html__( 'Course Name:', 'tutor' ),
619 esc_html__( 'Total Amount:', 'tutor' )
620 )
621 ),
622 'footer_text' => __( 'Please review the order and ensure everything is in place for the student\'s access to the course. Thank you.', 'tutor' ),
623 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
624 ),
625 ),
626 self::TO_ADMIN => array(
627 'new_order' => array(
628 'label' => __( 'New order placed', 'tutor' ),
629 'default' => 'on',
630 'template' => 'order_new_' . self::TO_ADMIN,
631 'tooltip' => __( 'New order emails are sent to chosen recipient(s) when a new order is received.', 'tutor' ),
632 'subject' => __( 'A New Order Has Been Placed on Your Platform!', 'tutor' ),
633 'heading' => __( 'A New Order Has Been Placed on Your Platform!', 'tutor' ),
634 'message' => wp_json_encode(
635 sprintf(
636 '
637 <p>%s</p>
638 <ul>
639 <li>%s {order_id}</li>
640 <li>%s {order_date}</li>
641 <li>%s {order_total}</li>
642 </ul>',
643 esc_html__( 'Below are the order details:', 'tutor' ),
644 esc_html__( 'Order ID:', 'tutor' ),
645 esc_html__( 'Order Date:', 'tutor' ),
646 esc_html__( 'Total Amount:', 'tutor' )
647 )
648 ),
649 'footer_text' => __( 'Please review the order and ensure everything is in place for the student\'s access to the course. Thank you.', 'tutor' ),
650 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
651 ),
652 'order_status_updated' => array(
653 'label' => __( 'Order status updated', 'tutor' ),
654 'default' => 'on',
655 'template' => 'order_updated_' . self::TO_ADMIN,
656 'tooltip' => __( 'Order status update emails are sent to chosen recipient(s) whenever a order status updated.', 'tutor' ),
657 'subject' => __( 'An Order\'s Status Has Been Updated to {order_status}', 'tutor' ),
658 'heading' => __( 'An Order\'s Status Has Been Updated to {order_status}', 'tutor' ),
659 'message' => wp_json_encode(
660 sprintf(
661 '
662 <p>%s</p>
663 <p>%s</p>
664 <ul>
665 <li>%s: {order_id}</li>
666 <li>%s: {order_date}</li>
667 <li>%s: {order_status}</li>
668 <li>%s: {course_name}</li>
669 <li>%s: {order_total}</li>
670 </ul>',
671 esc_html__( 'Hi {user_name},', 'tutor' ),
672 esc_html__( 'We\'re reaching out to let you know that the order status of {student_name} has been updated to {order_status}. Here is the summary of the order:', 'tutor' ),
673 esc_html__( 'Order ID', 'tutor' ),
674 esc_html__( 'Order Date', 'tutor' ),
675 esc_html__( 'Order Status', 'tutor' ),
676 esc_html__( 'Course Name', 'tutor' ),
677 esc_html__( 'Total Amount', 'tutor' )
678 )
679 ),
680 'footer_text' => __( 'Please review the order and ensure everything is in place for the student\'s access to the course. Thank you.', 'tutor' ),
681 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
682 ),
683 ),
684 );
685
686 return $email_array;
687 }
688 }
689