【问题标题】:Woocommerce new customer email to store managerWoocommerce 给商店经理的新客户电子邮件
【发布时间】:2018-09-13 06:39:12
【问题描述】:

选项 1

我正在尝试通过以下方式覆盖 Woocommerce 模板结构: http://docs.woothemes.com/document/template-structure/.

我要覆盖的文件是:your_template_directory/woocommerce/emails/customer-new-account.php。

在这个文件的最后我添加了以下代码:

<?php do_action( 'new_customer_registered', $user_login ); ?>
In functions.php add this:

function new_customer_registered_send_email_admin($user_login) {
  ob_start();
  do_action('woocommerce_email_header', 'New customer registered');
  $email_header = ob_get_clean();
  ob_start();
  do_action('woocommerce_email_footer');
  $email_footer = ob_get_clean();

  woocommerce_mail(
    get_bloginfo('admin_email'),
    get_bloginfo('name').' - New customer registered',
    $email_header.'<p>The user '.esc_html( $user_login ).' is registered to the website</p>'.$email_footer
  );
}
add_action('new_customer_registered', 'new_customer_registered_send_email_admin');

此代码用于向网站管理员发送电子邮件。 admin_email 由get_bloginfo 函数检索。但是,我正在尝试将电子邮件发送给 商店经理。知道在这种情况下应该使用什么函数或代码吗?

选项 2

另一种选择是将以下代码添加到functions.php文件并对其进行调整,以便它向商店经理而不是管理员发送通知:

/**
 * Notify admin when a new customer account is created
 */
add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_admin_notification' );
function woocommerce_created_customer_admin_notification( $customer_id ) {
  wp_send_new_user_notifications( $customer_id, 'admin' );
}

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    如下解决。我在functions.php 文件中添加了以下代码:

    /* SEND NEW CUSTOMER EMAIL TO KILIKILI */
    /* --- */
    add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2);
    
    function mycustom_headers_filter_function( $headers, $object ) {
        if ($object == 'customer_new_account') {
            $headers .= 'BCC: Store manager name <storemanager@domain.com>' . "\r\n";
        }
        return $headers;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-21
      • 2020-03-24
      • 1970-01-01
      • 2017-07-02
      • 2017-08-08
      • 2018-04-24
      相关资源
      最近更新 更多