我通过在functions.php中执行echo添加了一些自定义表单字段,并按照一些示例在电子邮件中设置自定义表单字段,但最近他们停止在电子邮件中显示,尽管我在自定义字段部分中按顺序详细信息获取所有这些字段。
/**
* Email include "Metadata" on Order Emails
*
*/
add_filter( 'woocommerce_email_order_meta_keys', 'xcsn_woocommerce_email_order_meta_keys' );
function xcsn_woocommerce_email_order_meta_keys( $keys ) {
global $post;
$post_id = $post->ID;
//For Package 1
if ( !empty( $post_id )) {
// Check the POST data is being submitted
if ( $_POST['acc1user'] ) {
$keys[] = 'acc1user';
// Writes directly into the email body
echo '<h2>Instagram Account No.1 Username</h2>';
$my_test_field_output = sanitize_text_field( $_POST['acc1user'] );
echo '<p>' . $my_test_field_output . '</p>';
}
if ( $_POST['acc1pass'] ) {
$keys[] = 'acc1pass';
// Writes directly into the email body
echo '<h2>Instagram Account No.1 Password</h2>';
$my_test_field_output = sanitize_text_field( $_POST['acc1pass'] );
echo '<p>' . $my_test_field_output . '</p>';
echo '</br>';
}
if ( $_POST['acc1audi'] ) {
$keys[] = 'acc1audi';
// Writes directly into the email body
echo '<h2>Instagram Account No.1 Audience</h2>';
$my_test_field_output = sanitize_text_field( $_POST['acc1audi'] );
echo '<p>' . $my_test_field_output . '</p>';
echo '</br>';
}
}
return $keys;
}
包括电子邮件代码中的元订单
{{1}}