简体   繁体   English

如何替换 OOTB woo 客户完成的订单 email?

[英]How do I replace the OOTB woo customer completed order email?

In a plugin I'm working on, I'm trying to replace the OOTB customer-completed-order email with a template in the plugin在我正在使用的插件中,我试图用插件中的模板替换 OOTB customer-completed-order email

Constructor:构造函数:

define( 'BKF_WC_EMAIL_PATH', plugin_dir_path( __FILE__ ) );
add_filter('wc_get_template', array($this, 'bkf_customer_completed_order_template'), PHP_INT_MAX, 5);

Function: Function:

    function bkf_customer_completed_order_template($template, $template_name, $args, $template_path, $default_path) {
        if( $template_name == 'emails/customer-completed-order.php' ) {
            $template = trailingslashit(BKF_WC_EMAIL_PATH) . 'templates/' . $template_name;
            return $template;
        }
    }

note the template is still pulling the default woo one请注意,模板仍在拉取默认的 woo one

Any thoughts/ideas are welcome!欢迎任何想法/想法!

Worked it out!解决了!

Instead of the method used in my original question, here's what worked for me:以下是对我有用的方法,而不是我原来问题中使用的方法:

I created a new class (similar to woocommerce/includes/emails/class-wc-email-customer-completed-order.php) - for demo purposes we'll call it My_Custom_Class我创建了一个新的 class(类似于 woocommerce/includes/emails/class-wc-email-customer-completed-order.php)——出于演示目的,我们将其称为My_Custom_Class

I then called like so in my constructor for the parent class I was working on:然后我在我正在处理的父 class 的构造函数中这样调用:

add_action('woocommerce_email_classes', array( $this, 'bk_register_email' ), PHP_INT_MAX, 1 );

And added this function:并添加了这个 function:

public function bk_register_email( $emails ) {
        require_once 'emails/my-custom-class.php';

        $emails['WC_Email_Customer_Completed_Order'] = new My_Custom_Class();

        return $emails;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 订购电子邮件:如何将等于零的小计替换为“待定”? - Order Email: How do I replace subtotals that are equal to zero with "TBD"? woocommerce_email_recipient_customer_completed_order挂钩未被调用 - woocommerce_email_recipient_customer_completed_order hook not being invoked woocommerce - 在插件中包含客户完成订单电子邮件模板 - woocommerce - include customer-completed-order email template in plugin 定位WooCommerce客户处理和完成的订单电子邮件通知 - Targetting WooCommerce customer processing and completed order email notifications 以编程方式创建“已完成”订单,无需将 email 发送给 WooCommerce 中的客户 - Create programmatically a “completed” order without sending email to customer in WooCommerce 在 woo BACS 付款设置中添加字段,该字段将始终为“订单号”并通过 email 发送给客户 - Adding field in woo BACS payment settings which will be always “order number” and send it via email to customer WooCommerce customer completed order email notification 查询订单备注是否包含特定字词并显示信息 - Check if order note contains specific words and display message in WooCommerce customer completed order email notification 在 WooCommerce 客户完成订单电子邮件通知中添加基于运输方式 ID 的消息 - Add message based on shipping method ID in WooCommerce customer completed order email notification 仅针对客户用户角色的已完成订单状态电子邮件通知的自定义消 - Custom message on completed order status email notification only for customer user role 基于 WooCommerce 客户完成订单 email 通知中的产品类别的条件文本 - Conditional text based on product category in WooCommerce customer completed order email notification
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM