customer_email = true; $this->template_base = plugin_dir_path( PREORVO_FILE ) . 'templates/'; $this->placeholders = array( '{order_number}' => '', '{release_date}' => '', ); parent::__construct(); } public function trigger( $order_id, $order = false ) { $this->setup_locale(); $order = $order ? $order : wc_get_order( $order_id ); if ( $order ) { $this->object = $order; $this->recipient = $order->get_billing_email(); $this->placeholders['{order_number}'] = $order->get_order_number(); $release = Preorvo_Orders::release_time( $order ); $this->placeholders['{release_date}'] = $release ? Preorvo_Product::format_date( $release ) : ''; } if ( $this->is_enabled() && $this->get_recipient() ) { $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); } $this->restore_locale(); } public function get_content_html() { return wc_get_template_html( $this->template_html, array( 'order' => $this->object, 'email_heading' => $this->get_heading(), 'additional_content' => $this->get_additional_content(), 'release_date' => $this->placeholders['{release_date}'], 'sent_to_admin' => false, 'plain_text' => false, 'email' => $this, ), '', $this->template_base ); } public function get_content_plain() { return wc_get_template_html( $this->template_plain, array( 'order' => $this->object, 'email_heading' => $this->get_heading(), 'additional_content' => $this->get_additional_content(), 'release_date' => $this->placeholders['{release_date}'], 'sent_to_admin' => false, 'plain_text' => true, 'email' => $this, ), '', $this->template_base ); } } class Preorvo_Email_Received extends Preorvo_Email { public function __construct() { $this->id = 'preorvo_preorder_received'; $this->title = __( 'Pre-order received', 'preorvo' ); $this->description = __( 'Sent to the customer when a pre-order is placed.', 'preorvo' ); $this->template_html = 'emails/preorder-received.php'; $this->template_plain = 'emails/plain/preorder-received.php'; parent::__construct(); } public function get_default_subject() { return __( 'Your pre-order #{order_number} is confirmed', 'preorvo' ); } public function get_default_heading() { return __( 'Pre-order confirmed', 'preorvo' ); } } class Preorvo_Email_Released extends Preorvo_Email { public function __construct() { $this->id = 'preorvo_preorder_released'; $this->title = __( 'Pre-order released', 'preorvo' ); $this->description = __( 'Sent to the customer when the pre-order is released for shipping.', 'preorvo' ); $this->template_html = 'emails/preorder-released.php'; $this->template_plain = 'emails/plain/preorder-released.php'; parent::__construct(); } public function get_default_subject() { return __( 'Your pre-order #{order_number} is on its way', 'preorvo' ); } public function get_default_heading() { return __( 'Your pre-order is released', 'preorvo' ); } }