【发布时间】:2022-06-27 20:38:14
【问题描述】:
我的客户想根据他们的位置按代理商将他的客户分开,每个代理商都有一个管理帐户。他希望将订单电子邮件发送到所选客户的代理机构。我为 ACF 的客户帐户创建了一个单选按钮,我想将订单电子邮件抄送给相关代理电子邮件,这就是我要阻止的地方。我无法添加发送电子邮件的正确条件。
代码 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 <exemple@email.com> \r\n";
}
}
return $headers;
}
【问题讨论】:
标签: php woocommerce notifications advanced-custom-fields