基于自定义客户字段的其他订单电子邮件

我需要将订单电子邮件的副本发送到自定义字段定义的第二个电子邮件地址。

我已经安装了标志性的自定义帐户字段插件, 并在用户上创建了一个自定义字段(我可以工作, 并且可以在admin中对其进行编辑)。 https://iconicwp.com/blog/the-ultimate-guide-to-adding-custom-woocommerce-user-account-fields/名为” iconic-register-email”

我还实现了此https://wordpress.stackexchange.com/questions/92020/adding-a-second-email-address-to-a-completed-order-in-woocommerce解决方案以发送额外的电子邮件。它适用于硬编码的电子邮件。

现在, 我需要结合解决方案, 但我无法使其正常工作。我已将发送电子邮件代码附加在标志性插件代码的底部。

add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2);
function mycustom_headers_filter_function( $headers, $object ) {

    $sae = 'a-custom-email@gmail.com';

    if ($object == 'customer_completed_order') {
        $headers .=  'BCC: Name <' . $sae . '>' . "\r\n";
    }

    return $headers;
}

此代码有效, 但我需要使用iconic-register-email字段。

需要获取用户的注册电子邮件地址, 因此当该用户下订单时, 会将订单副本发送到iconic-register-email定义的地址。

我对编码的知识非常有限, 请帮忙。我上线之前要添加的最后一件事。


#1


设法解决它。不知道这是否是最优雅的解决方案, 但它是否有效。

因为它是预定义的函数和数组, 所以我就是这样做的

function mycustom_headers_filter_function( $headers, $object ) {
    $sae = iconic_get_userdata( get_current_user_id(), 'iconic-register-email' );

    if ($object == 'new_order') {
        $headers .=  'BCC: <' . $sae . '>' . "\r\n";
    }

    return $headers;
}

来源:

https://www.srcmini02.com/62617.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_42212.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?