WooCommerce 自定义电子邮件模板“template_base”无法正常工作

时间:2021-03-24 20:05:43

标签: wordpress woocommerce

我正在开发一个插件来创建自定义电子邮件模板。

电子邮件模板将存储在插件本身中。但是,这不能正常工作。这是我的电子邮件类

 class SV_SplitEmail_New_Order extends WC_Email
{

    /**
     * Constructor.
     */
    public function __construct() {

        $this->id              = 'sv_split_new_order';
        $this->title           = __( 'New Order - Split Orders', 'woocommerce' );
        $this->description     = __( 'New order emails are sent to chosen recipient(s) when a new order is received. Compatible with Split and Plain orders. The default "New Order" email should be disabled.', 'woocommerce' );
        $this->customer_email  = false;
        $this->template_base   = SVTHEMING_PATH.'app/Providers/Order_Splitting/templates/';
        $this->template_html   = 'emails/admin-new-split-order.php';
        $this->placeholders    = array(
            '{order_date}'   => '',
            '{order_number}' => '',
        );

        // Triggers for this email.
        add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
        add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $this, 'trigger' ), 10, 2 );
        add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
        add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
        add_action( 'woocommerce_order_status_failed_to_completed_notification', array( $this, 'trigger' ), 10, 2 );
        add_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
        add_action( 'woocommerce_order_status_cancelled_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
        add_action( 'woocommerce_order_status_cancelled_to_completed_notification', array( $this, 'trigger' ), 10, 2 );
        add_action( 'woocommerce_order_status_cancelled_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );

        // Call parent constructor.
        parent::__construct();


        // Other settings.
        $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
    }

这在仪表板上正确显示。

enter image description here

但是,当电子邮件发送出去时,它们是空白的。

如果我将电子邮件模板文件放在网站的主题文件夹中,则可以正常工作。

然而,这并不理想,因为在部署/更新插件时,我将始终需要更新主题的电子邮件模板。

我已确保正确定义 $this->template_base,并且可以确认,因为仪表板显示了正确的文件。

我是不是遗漏了什么?

0 个答案:

没有答案