PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / trunk
Tutor LMS – eLearning and online course solution vtrunk
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
Cart 10 months ago PaymentGateways 3 weeks ago AdminMenu.php 9 months ago BillingController.php 1 year ago CartController.php 1 year ago CheckoutController.php 2 months ago CouponController.php 5 months ago Ecommerce.php 1 year ago EmailController.php 11 months ago HooksHandler.php 2 months ago OptionKeys.php 1 year ago OrderActivitiesController.php 1 year ago OrderController.php 6 months ago PaymentHandler.php 9 months ago Settings.php 9 months ago Tax.php 9 months ago currency.php 5 months ago
EmailController.php
715 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 * @since 3.2.3
263 *
264 * @param int $recipient the receiver id.
265 *
266 * @return array
267 */
268 public function get_option_data( $to_key, $trigger_key, $recipient ) {
269 $email_data = apply_filters( 'tutor_pro_user_email_template_option', get_option( 'email_template_data' ), $recipient );
270 $default_data = $this->get_email_data();
271
272 return isset( $email_data[ $to_key ][ $trigger_key ] ) ? $email_data[ $to_key ][ $trigger_key ] : $default_data[ $to_key ][ $trigger_key ];
273 }
274
275 /**
276 * Get instructor ids of an order's course, bundle.
277 *
278 * @since 3.6.0
279 *
280 * @param object $order_data order object.
281 *
282 * @return array
283 */
284 private function get_instructor_ids( $order_data ) {
285 $instructor_ids = array();
286 if ( ! isset( $order_data->items ) ) {
287 return $instructor_ids;
288 }
289
290 foreach ( $order_data->items as $item ) {
291 $item = (object) $item;
292 $item_id = $item->item_id ?? $item->id;
293 $course_id = null;
294
295 if ( OrderModel::TYPE_SINGLE_ORDER === $order_data->order_type ) {
296 $course_id = $item_id;
297 } else {
298 $plan_info = apply_filters( 'tutor_get_plan_info', null, $item_id );
299 if ( $plan_info && ! $plan_info->is_membership_plan ) {
300 $course_id = apply_filters( 'tutor_subscription_course_by_plan', $item_id, $order_data );
301 }
302 }
303
304 if ( $course_id ) {
305 $author_id = (int) get_post_field( 'post_author', $course_id );
306 if ( $author_id ) {
307 $instructor_ids[] = $author_id;
308 }
309 }
310 }
311
312 return $instructor_ids;
313 }
314
315 /**
316 * Send mail once new order place
317 *
318 * @since 3.0.0
319 *
320 * @param array $order_data Order data.
321 *
322 * @return void
323 */
324 public function order_placed( array $order_data ) {
325
326 $order_data = (object) $order_data;
327 $order_data->items = (object) $order_data->items;
328
329 $student_ids = array( $order_data->user_id );
330 $admin_ids = array();
331 $instructor_ids = $this->get_instructor_ids( $order_data );
332
333 // Set admin user ids.
334 $admin_users = get_users( array( 'role' => 'administrator' ) );
335
336 foreach ( $admin_users as $admin_user ) {
337 $admin_ids[] = $admin_user->ID;
338 }
339
340 if ( tutor()->has_pro ) {
341 if ( tutor_utils()->get_option( self::TO_STUDENTS . '.new_order' ) ) {
342 $this->send_email_to( self::TO_STUDENTS, 'new_order', $student_ids, $order_data->id );
343 }
344
345 if ( tutor_utils()->get_option( self::TO_ADMIN . '.new_order' ) ) {
346 $this->send_email_to( self::TO_ADMIN, 'new_order', $admin_ids, $order_data->id );
347 }
348
349 if ( tutor_utils()->get_option( self::TO_TEACHERS . '.new_order' ) ) {
350 $this->send_email_to( self::TO_TEACHERS, 'new_order', $instructor_ids, $order_data->id );
351 }
352 } else {
353 $this->send_email_to( self::TO_STUDENTS, 'new_order', $student_ids, $order_data->id );
354 $this->send_email_to( self::TO_ADMIN, 'new_order', $admin_ids, $order_data->id );
355 $this->send_email_to( self::TO_TEACHERS, 'new_order', $instructor_ids, $order_data->id );
356 }
357 }
358
359 /**
360 * Send mail once new order place
361 *
362 * @since 3.0.0
363 *
364 * @param int $order_id Order id.
365 * @param string $prev_payment_status Order previous payment status.
366 * @param string $new_payment_status Order new status.
367 *
368 * @return void
369 */
370 public function order_updated( $order_id, $prev_payment_status, $new_payment_status ) {
371
372 $order_data = ( new OrderModel() )->get_order_by_id( $order_id );
373 $order_data->items = (object) $order_data->items;
374
375 if ( OrderModel::PAYMENT_PARTIALLY_REFUNDED === $new_payment_status || ( OrderModel::PAYMENT_REFUNDED === $new_payment_status && OrderModel::ORDER_COMPLETED === $order_data->order_status ) ) {
376 return;
377 }
378
379 $student_ids = array( $order_data->user_id );
380 $admin_ids = array();
381 $instructor_ids = $this->get_instructor_ids( $order_data );
382
383 // Set admin user ids.
384 $admin_users = get_users( array( 'role' => 'administrator' ) );
385
386 foreach ( $admin_users as $admin_user ) {
387 $admin_ids[] = $admin_user->ID;
388 }
389
390 if ( tutor_utils()->get_option( self::TO_STUDENTS . '.order_status_updated' ) ) {
391 $this->send_email_to( self::TO_STUDENTS, 'order_status_updated', $student_ids, $order_data->id );
392 }
393
394 if ( tutor_utils()->get_option( self::TO_ADMIN . '.order_status_updated' ) ) {
395 $this->send_email_to( self::TO_TEACHERS, 'order_status_updated', $instructor_ids, $order_data->id );
396 }
397
398 if ( tutor_utils()->get_option( self::TO_TEACHERS . '.order_status_updated' ) ) {
399 $this->send_email_to( self::TO_ADMIN, 'order_status_updated', $admin_ids, $order_data->id );
400 }
401 }
402
403 /**
404 * Send email to a specific recipient
405 *
406 * @since 3.0.0
407 *
408 * @param string $recipient_type Recipient type like
409 * email_to_students, email_to_teachers, email_to_admin.
410 * @param string $email_type New order/ order status updated.
411 * @param array $recipients Recipients ids.
412 * @param int $order_id Order id.
413 *
414 * @return void
415 */
416 private function send_email_to( $recipient_type, $email_type, $recipients, $order_id ) {
417
418 $site_url = get_bloginfo( 'url' );
419 $site_name = get_bloginfo( 'name' );
420 $order_data = ( new OrderModel() )->get_order_by_id( $order_id );
421 $recipients = array_unique( $recipients );
422 foreach ( $recipients as $recipient ) {
423 // Ignore email when teachers himself admin.
424 // because admin email has already been send.
425 if ( 'email_to_teachers' === $recipient_type && user_can( $recipient, 'manage_options' ) ) {
426 continue;
427 }
428
429 /**
430 * Notification preference check for student.
431 *
432 * @since 3.1.0
433 */
434 if ( self::TO_STUDENTS === $recipient_type ) {
435 $trigger_name = $email_type;
436 $user_id = $recipient;
437
438 $notification_enabled = apply_filters( 'tutor_is_notification_enabled_for_user', true, 'email', self::TO_STUDENTS, $trigger_name, $user_id );
439 if ( ! $notification_enabled ) {
440 continue;
441 }
442 }
443
444 $user_data = get_userdata( $recipient );
445 $option_data = $this->get_option_data( $recipient_type, $email_type, $recipient );
446 $header = 'Content-Type: ' . $this->get_content_type() . "\r\n";
447 $header = apply_filters( 'new_order_email_header', $header );
448
449 $replacable['{testing_email_notice}'] = '';
450 $replacable['{user_name}'] = tutor_utils()->get_user_name( $user_data );
451 $replacable['{site_url}'] = $site_url;
452 $replacable['{site_name}'] = $site_name;
453
454 if ( OrderModel::TYPE_SUBSCRIPTION === $order_data->order_type ) {
455 $plan = ( new PlanModel() )->get_plan( $order_data->items[0]->id );
456 $replacable['{course_name}'] = $plan->plan_name;
457 } else {
458 $replacable['{course_name}'] = count( $order_data->items ) > 1 ? _n( 'Course', 'Courses', count( $order_data->items ), 'tutor' ) : $order_data->items[0]->title;
459 }
460
461 $replacable['{admin_order_url}'] = admin_url( 'admin.php?page=tutor_orders&action=edit&id=' . $order_id );
462
463 $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' );
464
465 $replacable['{order_id}'] = '#' . $order_data->id;
466 $replacable['{order_date}'] = tutor_i18n_get_formated_date( $order_data->created_at_gmt, get_option( 'date_format' ) );
467 $replacable['{order_total}'] = tutor_get_formatted_price( $order_data->total_price );
468 $replacable['{order_status}'] = tutor_utils()->translate_dynamic_text( $order_data->order_status );
469 $replacable['{order_payment_status}'] = tutor_utils()->translate_dynamic_text( $order_data->payment_status );
470
471 $student = get_userdata( $order_data->student->id );
472 if ( is_a( $student, 'WP_User' ) ) {
473 $replacable['{student_name}'] = $student->display_name;
474 }
475
476 $replacable['{dashboard_url}'] = tutor_utils()->get_tutor_dashboard_page_permalink();
477 $replacable['{logo}'] = isset( $option_data['logo'] ) ? $option_data['logo'] : '';
478 $replacable['{email_heading}'] = $this->get_replaced_text( $option_data['heading'], array_keys( $replacable ), array_values( $replacable ) );
479
480 $replacable['{email_message}'] = $this->get_replaced_text( $this->prepare_message( $option_data['message'] ), array_keys( $replacable ), array_values( $replacable ) );
481
482 $replacable['{footer_text}'] = $this->get_replaced_text( $option_data['footer_text'] ?? '', array_keys( $replacable ), array_values( $replacable ) );
483
484 $subject = $this->get_replaced_text( $option_data['subject'], array_keys( $replacable ), array_values( $replacable ) );
485
486 ob_start();
487 $this->tutor_load_email_template( 'order_new_' . $recipient_type );
488 $email_tpl = apply_filters( 'tutor_email_tpl_' . $recipient_type, ob_get_clean() );
489 $message = html_entity_decode( $this->get_message( $email_tpl, array_keys( $replacable ), array_values( $replacable ) ) );
490
491 $enable_queue = tutor()->has_pro && tutor_utils()->get_option( 'tutor_email_disable_wpcron' );
492
493 $this->send( $user_data->user_email, $subject, $message, $header, array(), $enable_queue );
494 }
495 }
496
497 /**
498 * Setup email data
499 *
500 * @since 3.0.0
501 *
502 * @param array $email_config Default email config data.
503 *
504 * @return array.
505 */
506 public function setup_email_config( $email_config ) {
507 $order_email = $this->get_email_data();
508
509 $email_config[ self::TO_STUDENTS ]['new_order'] = $order_email[ self::TO_STUDENTS ]['new_order'];
510 $email_config[ self::TO_STUDENTS ]['order_status_updated'] = $order_email['email_to_students']['order_status_updated'];
511
512 $email_config[ self::TO_TEACHERS ]['new_order'] = $order_email['email_to_teachers']['new_order'];
513 $email_config[ self::TO_TEACHERS ]['order_status_updated'] = $order_email['email_to_teachers']['order_status_updated'];
514
515 $email_config[ self::TO_ADMIN ]['new_order'] = $order_email['email_to_admin']['new_order'];
516 $email_config[ self::TO_ADMIN ]['order_status_updated'] = $order_email['email_to_admin']['order_status_updated'];
517
518 return $email_config;
519 }
520
521 /**
522 * Get email data.
523 *
524 * @return array
525 */
526 public function get_email_data() {
527 $email_array = array(
528 self::TO_STUDENTS => array(
529 'new_order' => array(
530 'label' => __( 'New Order Placed', 'tutor' ),
531 'default' => 'on',
532 'template' => 'order_new_' . self::TO_STUDENTS,
533 'tooltip' => __( 'New order emails are sent to chosen recipient(s) when a new order is received.', 'tutor' ),
534 'subject' => __( 'Your order has been received! 🎉', 'tutor' ),
535 'heading' => __( 'Your order has been received!', 'tutor' ),
536 'message' => wp_json_encode(
537 sprintf(
538 '
539 <p>%s {user_name},</p>
540 <p>%s</p>
541 <div>
542 <p>%s</p>
543 <ul>
544 <li>%s {order_id}</li>
545 <li>%s {order_date}</li>
546 <li>%s {order_total}</li>
547 </ul>
548 </div>',
549 esc_html__( 'Hi', 'tutor' ),
550 esc_html__( 'Thank you for your order. We\'ve received your order successfully, and it is now being processed.', 'tutor' ),
551 esc_html__( 'Below are the details of your order:', 'tutor' ),
552 esc_html__( 'Order ID:', 'tutor' ),
553 esc_html__( 'Order Date:', 'tutor' ),
554 esc_html__( 'Total Amount:', 'tutor' )
555 )
556 ),
557 'footer_text' => __( 'We will let you know once your order has been completed and is ready for access.', 'tutor' ),
558 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
559 ),
560 'order_status_updated' => array(
561 'label' => __( 'Order Status Updated', 'tutor' ),
562 'default' => 'on',
563 'template' => 'order_updated_' . self::TO_STUDENTS,
564 'tooltip' => __( 'Order status update emails are sent to chosen recipient(s) whenever a order status updated.', 'tutor' ),
565 'subject' => __( 'Your Order Status Has Been Updated to {order_status} ', 'tutor' ),
566 'heading' => __( 'Your Order Status Has Been Updated to {order_status}', 'tutor' ),
567 'message' => wp_json_encode(
568 sprintf(
569 '
570 <p>%s</p>
571 <p>%s</p>
572 <ul>
573 <li>%s {order_id}</li>
574 <li>%s {order_status}</li>
575 <li>%s {course_name}</li>
576 <li>%s {order_date}</li>
577 <li>%s {order_total}</li>
578 </ul>',
579 esc_html__( 'Hi {user_name},', 'tutor' ),
580 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' ),
581 esc_html__( 'Order ID:', 'tutor' ),
582 esc_html__( 'Order Status:', 'tutor' ),
583 esc_html__( 'Course:', 'tutor' ),
584 esc_html__( 'Order Date:', 'tutor' ),
585 esc_html__( 'Total Amount:', 'tutor' )
586 )
587 ),
588 'footer_text' => __( 'We will let you know once your order has been completed and is ready for access.', 'tutor' ),
589 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
590 ),
591 ),
592 self::TO_TEACHERS => array(
593 'new_order' => array(
594 'label' => __( 'New Order Placed', 'tutor' ),
595 'default' => 'on',
596 'template' => 'order_new_' . self::TO_TEACHERS,
597 'tooltip' => __( 'New order emails are sent to chosen recipient(s) when a new order is received.', 'tutor' ),
598 'subject' => __( 'A New Student Has Enrolled in Your Course! 🎉', 'tutor' ),
599 'heading' => __( 'A New Student Has Enrolled in Your Course!', 'tutor' ),
600 'message' => wp_json_encode(
601 sprintf(
602 '
603 <p>%s {user_name},</p>
604 <p>%s</p>
605 <ul>
606 <li>%s {student_name}</li>
607 <li>%s {order_id}</li>
608 <li>%s {order_date}</li>
609 <li>%s {order_payment_status}</li>
610 </ul>',
611 esc_html__( 'Hi', 'tutor' ),
612 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' ),
613 esc_html__( 'Student Name:', 'tutor' ),
614 esc_html__( 'Order ID:', 'tutor' ),
615 esc_html__( 'Order Date:', 'tutor' ),
616 esc_html__( 'Payment Status:', 'tutor' )
617 )
618 ),
619 'footer_text' => __( 'Please review the order and ensure everything is in place for the student\'s access to the course. Thank you.', 'tutor' ),
620 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
621 ),
622 'order_status_updated' => array(
623 'label' => __( 'Order Status Updated', 'tutor' ),
624 'default' => 'on',
625 'template' => 'order_updated_' . self::TO_TEACHERS,
626 'tooltip' => __( 'Order status update emails are sent to chosen recipient(s) whenever a order status updated.', 'tutor' ),
627 'subject' => __( 'Instructor Notice: Your Student\'s Order Status is Now {order_status}', 'tutor' ),
628 'heading' => __( 'Instructor Notice: Your Student\'s Order Status is Now {order_status}', 'tutor' ),
629 'message' => wp_json_encode(
630 sprintf(
631 '
632 <p>%s</p>
633 <p>%s</p>
634 <ul>
635 <li>%s {order_id}</li>
636 <li>%s {order_status}</li>
637 <li>%s {course_name}</li>
638 <li>%s {order_total}</li>
639 </ul>',
640 esc_html__( 'Hi {user_name},', 'tutor' ),
641 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' ),
642 esc_html__( 'Order ID:', 'tutor' ),
643 esc_html__( 'Order Status:', 'tutor' ),
644 esc_html__( 'Course Name:', 'tutor' ),
645 esc_html__( 'Total Amount:', 'tutor' )
646 )
647 ),
648 'footer_text' => __( 'Please review the order and ensure everything is in place for the student\'s access to the course. Thank you.', 'tutor' ),
649 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
650 ),
651 ),
652 self::TO_ADMIN => array(
653 'new_order' => array(
654 'label' => __( 'New Order Placed', 'tutor' ),
655 'default' => 'on',
656 'template' => 'order_new_' . self::TO_ADMIN,
657 'tooltip' => __( 'New order emails are sent to chosen recipient(s) when a new order is received.', 'tutor' ),
658 'subject' => __( 'A New Order Has Been Placed on Your Platform!', 'tutor' ),
659 'heading' => __( 'A New Order Has Been Placed on Your Platform!', 'tutor' ),
660 'message' => wp_json_encode(
661 sprintf(
662 '
663 <p>%s</p>
664 <ul>
665 <li>%s {order_id}</li>
666 <li>%s {order_date}</li>
667 <li>%s {order_total}</li>
668 </ul>',
669 esc_html__( 'Below are the order details:', 'tutor' ),
670 esc_html__( 'Order ID:', 'tutor' ),
671 esc_html__( 'Order Date:', 'tutor' ),
672 esc_html__( 'Total Amount:', 'tutor' )
673 )
674 ),
675 'footer_text' => __( 'Please review the order and ensure everything is in place for the student\'s access to the course. Thank you.', 'tutor' ),
676 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
677 ),
678 'order_status_updated' => array(
679 'label' => __( 'Order Status Updated', 'tutor' ),
680 'default' => 'on',
681 'template' => 'order_updated_' . self::TO_ADMIN,
682 'tooltip' => __( 'Order status update emails are sent to chosen recipient(s) whenever a order status updated.', 'tutor' ),
683 'subject' => __( 'An Order\'s Status Has Been Updated to {order_status}', 'tutor' ),
684 'heading' => __( 'An Order\'s Status Has Been Updated to {order_status}', 'tutor' ),
685 'message' => wp_json_encode(
686 sprintf(
687 '
688 <p>%s</p>
689 <p>%s</p>
690 <ul>
691 <li>%s: {order_id}</li>
692 <li>%s: {order_date}</li>
693 <li>%s: {order_status}</li>
694 <li>%s: {course_name}</li>
695 <li>%s: {order_total}</li>
696 </ul>',
697 esc_html__( 'Hi {user_name},', 'tutor' ),
698 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' ),
699 esc_html__( 'Order ID', 'tutor' ),
700 esc_html__( 'Order Date', 'tutor' ),
701 esc_html__( 'Order Status', 'tutor' ),
702 esc_html__( 'Course Name', 'tutor' ),
703 esc_html__( 'Total Amount', 'tutor' )
704 )
705 ),
706 'footer_text' => __( 'Please review the order and ensure everything is in place for the student\'s access to the course. Thank you.', 'tutor' ),
707 // 'placeholders' => EmailPlaceholder::only( array( 'site_url', 'site_name', 'instructor_name', 'review_url', 'instructor_email', 'signup_time' ) ),
708 ),
709 ),
710 );
711
712 return $email_array;
713 }
714 }
715