template_base = RTKT_DIR . 'templates/'; $this->template_html = 'emails/' . $this->template_name . '.php'; $this->template_plain = 'emails/plain/' . $this->template_name . '.php'; $this->placeholders = array_merge( array( '{request_number}' => '', '{order_number}' => '', '{request_type}' => '', ), $this->placeholders ); parent::__construct(); } /** * Prepare placeholders and the recipient for a request. * * @param Request $request Request. * @return void */ protected function setup( Request $request ) { $this->setup_locale(); $this->request = $request; $this->object = $request->order(); $this->placeholders['{request_number}'] = $request->number(); $this->placeholders['{order_number}'] = $this->object ? $this->object->get_order_number() : (string) ( $request->meta( 'statement', array() )['order_number'] ?? '' ); $this->placeholders['{request_type}'] = Labels::type_lower( $request->type() ); if ( $this->object ) { $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); } } /** * Send and restore the locale. * * @return bool */ protected function dispatch() { $sent = false; if ( $this->is_enabled() && $this->get_recipient() ) { $sent = (bool) $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); } $this->restore_locale(); return $sent; } /** * Template variables. * * @param bool $plain Plain text. * @return array */ protected function template_args( $plain ) { return array_merge( array( 'request' => $this->request, 'order' => $this->object, 'email_heading' => $this->get_heading(), 'additional_content' => $this->get_additional_content(), 'sent_to_admin' => false, 'plain_text' => $plain, 'email' => $this, ), $this->extra ); } /** * HTML content. * * @return string */ public function get_content_html() { return wc_get_template_html( $this->template_html, $this->template_args( false ), 'woocommerce/returnkit/', $this->template_base ); } /** * Plain content. * * @return string */ public function get_content_plain() { return wc_get_template_html( $this->template_plain, $this->template_args( true ), 'woocommerce/returnkit/', $this->template_base ); } /** * Template overrides live in yourtheme/woocommerce/returnkit/emails/. * * @param string $template Template. * @return string */ public function get_theme_template_file( $template ) { return get_stylesheet_directory() . '/woocommerce/returnkit/' . $template; } }