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