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