Woocommerce New Customer Admin Notification Email

后端 未结 4 1655
温柔的废话
温柔的废话 2021-01-03 02:56

I am building an ecommerce site using Wordpress and Woocommerce. I need the site to send out a notification email to the site administrator when a new customer account is re

相关标签:
4条回答
  • 2021-01-03 03:20

    I was pulling my hair out trying to figure this same issue out and after going back and forth with the developers the default is to not send new customer registration notification emails to admin.

    After trying various email plugins and even resorting to using WP SMTP Email, I finally decided to leave it alone.

    That said, WooCommerce 2.0 was released today so it may be built in the new version.

    0 讨论(0)
  • 2021-01-03 03:26

    I'm assuming that you are using html inside emails. If you are using plain text the procedure is similar.

    You need to override the woocommerce template structure. Here you can find how: http://docs.woothemes.com/document/template-structure/.

    Actually the only file you need to override is your_template_directory/woocommerce/emails/customer-new-account.php.

    At the end of this file add this line of code:

    <?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');
    
    0 讨论(0)
  • 2021-01-03 03:30

    the answers is in the emails sections of "woocommerce / settings"

    simply change the from email to wordpress@yourdomain.com

    worked for me as i also had the same issues

    0 讨论(0)
  • 2021-01-03 03:31
    add_action('woocommerce_created_customer', 'admin_email_on_registration', 10 , 1);
    function admin_email_on_registration( $customer_id) {
        wp_new_user_notification( $customer_id );
    }
    

    woocommerce_created_customer is hook which is called when user created by woocommerce. It only sends notification to customer. we will use wp_new_user_notification() function to send notification to Admin.

    0 讨论(0)
提交回复
热议问题