| 1 |
<?php |
| 2 |
/** |
| 3 |
* LP_Email_Enrolled_Course_User. |
| 4 |
* |
| 5 |
* @author ThimPress |
| 6 |
* @package Learnpress/Classes |
| 7 |
* @extends LP_Email |
| 8 |
* @version 3.0.1 |
| 9 |
*/ |
| 10 |
|
| 11 |
/** |
| 12 |
* Prevent loading this file directly |
| 13 |
*/ |
| 14 |
defined( 'ABSPATH' ) || exit(); |
| 15 |
|
| 16 |
if ( ! class_exists( 'LP_Email_Enrolled_Course_User' ) ) { |
| 17 |
|
| 18 |
/** |
| 19 |
* Class LP_Email_Enrolled_Course_User |
| 20 |
*/ |
| 21 |
class LP_Email_Enrolled_Course_User extends LP_Email_Type_Enrolled_Course { |
| 22 |
/** |
| 23 |
* LP_Email_Enrolled_Course_User constructor. |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
$this->id = 'enrolled-course-user'; |
| 27 |
$this->title = __( 'User', 'learnpress' ); |
| 28 |
$this->description = __( 'Send this email to the user when they have enrolled in the course.', 'learnpress' ); |
| 29 |
|
| 30 |
$this->default_subject = __( '[{{site_title}}] You have enrolled in the course', 'learnpress' ); |
| 31 |
$this->default_heading = __( 'You have enrolled in the course', 'learnpress' ); |
| 32 |
|
| 33 |
parent::__construct(); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Trigger email. |
| 38 |
* Receive 2 params: order_id, old_status |
| 39 |
* |
| 40 |
* @param array $params |
| 41 |
* |
| 42 |
* @throws Exception |
| 43 |
* @since 4.1.1 |
| 44 |
* @author tungnx |
| 45 |
*/ |
| 46 |
public function handle( array $params ) { |
| 47 |
if ( ! $this->check_and_set( $params ) ) { |
| 48 |
return; |
| 49 |
} |
| 50 |
|
| 51 |
$user_email = ''; |
| 52 |
if ( $this->_user ) { |
| 53 |
$user_email = $this->_user->get_email(); |
| 54 |
} else { |
| 55 |
$user_email = $this->_order->get_user_email(); |
| 56 |
} |
| 57 |
|
| 58 |
$this->set_data_content(); |
| 59 |
$this->set_receive( $user_email ); |
| 60 |
$this->send_email(); |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
return new LP_Email_Enrolled_Course_User(); |
| 66 |
|