BCC电子邮件订单通知与ACF有关

发布于 2025-02-10 17:09:35 字数 2304 浏览 1 评论 0原文

我的客户想根据其位置将其客户分开,每个机构都有一个管理帐户。他希望订单电子邮件转到所选客户的代理商。我使用ACF创建了一个用于客户帐户的广播按钮,我想将订单电子邮件CC发送给有关代理商的电子邮件,这就是我要阻止的地方。我无法添加正确的条件来发送电子邮件。

代码ACF:

    if( function_exists('acf_add_local_field_group') ):

acf_add_local_field_group(array(
    'key' => 'group_62b97460daadb',
    'title' => 'Agence Barrault / AutoFit',
    'fields' => array(
        array(
            'key' => 'field_62b9746e368c2',
            'label' => 'Sélectionner une Agence',
            'name' => 'agence',
            'type' => 'radio',
            'instructions' => '',
            'required' => 1,
            'conditional_logic' => 0,
            'wrapper' => array(
                'width' => '',
                'class' => '',
                'id' => '',
            ),
            'choices' => array(
                1 => 'Test',
                2 => 'La Rochelle',
                3 => 'Saintes',
                4 => 'Rochefort',
            ),
            'allow_null' => 0,
            'other_choice' => 0,
            'default_value' => 1,
            'layout' => 'vertical',
            'return_format' => 'value',
            'save_other_choice' => 0,
        ),
    ),
    'location' => array(
        array(
            array(
                'param' => 'user_form',
                'operator' => '==',
                'value' => 'all',
            ),
        ),
    ),
    'menu_order' => 0,
    'position' => 'normal',
    'style' => 'default',
    'label_placement' => 'top',
    'instruction_placement' => 'label',
    'hide_on_screen' => '',
    'active' => true,
    'description' => '',
    'show_in_rest' => 0,
));

endif;      

我的代码:

add_filter( 'woocommerce_email_headers', 'bcc_to_email_headers', 10, 3 );
function bcc_to_email_headers( $headers, $email_id, $order ) {

    if ( $email_id === 'new_order' ) {
        $value = get_field( 'field_62b9746e368c2', 'agence' );

        if ( $value == [1] ) {
            $headers .= "Bcc: Name <[email protected]> \r\n";
        }
    }
    return $headers;
}

my client wants to separate his clients by Agency according to their location, each agency has an administration account. He would like the order email to go to the selected customer's agency. I created a radio button for customer accounts with ACF and I want to CC the order email to the agency email in question and that's where I'm blocking. I can't add the right condition to send the email.

Code ACF :

    if( function_exists('acf_add_local_field_group') ):

acf_add_local_field_group(array(
    'key' => 'group_62b97460daadb',
    'title' => 'Agence Barrault / AutoFit',
    'fields' => array(
        array(
            'key' => 'field_62b9746e368c2',
            'label' => 'Sélectionner une Agence',
            'name' => 'agence',
            'type' => 'radio',
            'instructions' => '',
            'required' => 1,
            'conditional_logic' => 0,
            'wrapper' => array(
                'width' => '',
                'class' => '',
                'id' => '',
            ),
            'choices' => array(
                1 => 'Test',
                2 => 'La Rochelle',
                3 => 'Saintes',
                4 => 'Rochefort',
            ),
            'allow_null' => 0,
            'other_choice' => 0,
            'default_value' => 1,
            'layout' => 'vertical',
            'return_format' => 'value',
            'save_other_choice' => 0,
        ),
    ),
    'location' => array(
        array(
            array(
                'param' => 'user_form',
                'operator' => '==',
                'value' => 'all',
            ),
        ),
    ),
    'menu_order' => 0,
    'position' => 'normal',
    'style' => 'default',
    'label_placement' => 'top',
    'instruction_placement' => 'label',
    'hide_on_screen' => '',
    'active' => true,
    'description' => '',
    'show_in_rest' => 0,
));

endif;      

My code :

add_filter( 'woocommerce_email_headers', 'bcc_to_email_headers', 10, 3 );
function bcc_to_email_headers( $headers, $email_id, $order ) {

    if ( $email_id === 'new_order' ) {
        $value = get_field( 'field_62b9746e368c2', 'agence' );

        if ( $value == [1] ) {
            $headers .= "Bcc: Name <[email protected]> \r\n";
        }
    }
    return $headers;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

万劫不复 2025-02-17 17:09:35

您需要将此行更改

if ( $value == [1] ) {

if ( $value === 1 ) {

You need to change this line

if ( $value == [1] ) {

to

if ( $value === 1 ) {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文