douou8954 2017-06-07 13:56
浏览 110

WooCommerce已完成订单的附加电子邮件

I have a question, which need a community support as I couldn't find anything on the web including WooCommerce support forum.

I have a WooCommerce site which is a closed e-commerce store used by local chain of restaurants. Each time stores order anything, GM would also like a email sent to him on completed order, so he can either block the order or approve it. GM1 is responsible for Store1, Store2 and Store3; GM2 is responsible for Store4, Store5, and Store 6 and so forth.

With the help of internet, this is what I have so far in function.php. Function is working properly and getting triggered, but all 3 GMs are getting email, but in theory, only one GM should get email. GM1 for Store1 OR Store2 OR Store3; and GM2 should get email if Store4 OR Store5 OR Store6 orders.

Really appreciate if somebody can point me to the right direction or atleast let me know why all three ifs are getting triggered.

add_filter( 'woocommerce_email_recipient_customer_completed_order', 'your_email_recipient_filter_function', 10, 2);

function your_email_recipient_filter_function($recipient, $object) {
    if( 'Store1@store.com' || 'Store2@store.com' || 'Store3@store.com' == $recipient ){
        $recipient = $recipient .= ', GM1@store.com';
    }

    if( 'Store4@store.com' || 'Store5@store.com' || 'Store6@store.com' == $recipient ){
        $recipient = $recipient .= ', GM2@store.com';
    }

    if( 'Store7@store.com' || 'Store8@store.com' || 'Store9@store.com' == $recipient ){
        $recipient = $recipient .= ', GM3@store.com';
    }

    return $recipient;
}

Thanks.

  • 写回答

1条回答 默认 最新

  • dpyln64620 2017-06-08 13:35
    关注

    I ended up using an array() as below which seems to be working:

    function your_email_recipient_filter_function( $recipient, $order ) {
    
    $Stores1 = array('Store1@store.com', 'Store2@store.com', 'Store3@store.com');
    $Stores2 = array('Store4@store.com', 'Store5@store.com', 'Store6@store.com');
    $Stores3 = array('Store7@store.com', 'Store8@store.com', 'Store9@store.com');
    
    $StoreEmail =  $order->billing_email;
    
    if ( in_array( $StoreEmail, $Stores1)) {
        $recipient .= ', GM1@store.com';
    } elseif ( in_array( $StoreEmail, $Stores2) ) {
        $recipient .= ', GM2@store.com';
    } elseif ( in_array( $StoreEmail, $Stores3) ) {
        $recipient .= ', GM2@store.com';
    } 
    return $recipient;
    }
    add_filter( 'woocommerce_email_recipient_customer_completed_order', 'your_email_recipient_filter_function', 10, 2);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口