【问题标题】:Woocommerce - Send email to other people [duplicate]Woocommerce - 向其他人发送电子邮件[重复]
【发布时间】:2019-10-11 22:17:22
【问题描述】:

我有一个包含其他客户电子邮件帐户的自定义字段。

我的想法是,当订单更改状态 WAIT、PENDING、PROCESSING 或 COMPLETED 时,它将到达此字段中配置的电子邮件。

这可能吗?

没有需要编程的问题,但是不知道用什么钩子。

谢谢。

【问题讨论】:

    标签: woocommerce


    【解决方案1】:

    在您的活动主题的functions.php中添加以下代码sn-p -

    function add_cc_to_wc_order_emails( $header, $mail_id, $mail_obj ) {
        $available_for = array( 'customer_on_hold_order', 'customer_processing_order', 'customer_completed_order' );
        if( in_array( $mail_id, $available_for ) ) {
            $cc_email = 'addyour@ccmail.com';
            $cc_username = "yourCCUser";
            $formatted_email = utf8_decode( $cc_username . ' <' . $cc_email . '>' );
            $header .= 'Cc: ' . $formatted_email . "\r\n";
        }
        return $header;
    }
    add_filter( 'woocommerce_email_headers', 'add_cc_to_wc_order_emails', 99, 3 );
    

    【讨论】:

    • 谢谢,我会试试的。
    【解决方案2】:

    这可能非常有用: https://www.skyverge.com/blog/add-woocommerce-email-recipients-conditionally/ 我会看一下注意事项部分。

    【讨论】:

      【解决方案3】:

      例如,您可以使用woocommerce_order_status_changed 钩子在每次订单状态更改时通知某人,如下例所示:

      add_action('woocommerce_order_status_changed', 'send_custom_email_notifications', 10, 4 );
      function send_custom_email_notifications( $order_id, $old_status, $new_status, $order ){          
      
          $to_email    = 'john.doe@gmail.com'; // <= Replace with your email custom field (the recipient)
          $shop_name   = __('Shop name'); // Set the shop name
          $admin_email = 'shop@email.com'; // Set default admin email
      
          $subject  = sprintf( __('Order %s has changed to "%s" status'), $order_id, $new_status ); // The subject
          $message  = sprintf( __('Order %s has changed to "%s" status'), $order_id, $new_status ); // Message content
          $headers  = sprintf( __('From: %s <%s>'), $shop_name, $admin_email ) . "\r\n"; // From admin email
      
          wp_mail( $to_email, $subject, $message, $headers ); // Send the email
      }
      

      代码在您的活动子主题(或活动主题)的functions.php 文件中。经过测试和工作

      【讨论】:

      • 嗨 Loic,阿兹特克人。感谢您的回答。我想我没有很好地解释一部分。我需要的是发送发送给其他人的相同邮件。这不是通知,而是发送标准的 Woocommerce 邮件。可能是抄送。
      • 嗨 Loic,您知道当您单击将产品添加到购物车时,有一些过滤器可以进行验证(例如过滤器 woocommerce_add_to_cart_validation)。是否有插件允许使用 ajax 调用来完成此验证以避免页面刷新?我无法找到如何搜索它,或者可能我必须自己做?也许您已经回答了这样的问题?我非常确信这样的事情已经存在..
      猜你喜欢
      • 2021-01-26
      • 2015-10-09
      • 1970-01-01
      • 1970-01-01
      • 2011-06-21
      • 1970-01-01
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      相关资源
      最近更新 更多