Пользовательские поля исчезли из нового электронного адреса заказа, Woocomerce

Я добавил некоторые настраиваемые поля формы, выполнив echo в functions.php, и следовал некоторым примерам для настройки настраиваемых полей формы в электронной почте, но недавно они перестали отображаться в электронных письмах, хотя я получаю все эти поля в деталях заказа в части пользовательских полей.

    function self_added_checkout_fieldsPk1($fields)
{
echo '<div class="row" style="text-aign:center">
<div class="col m4 offset-m4" align="center">
<ul class="collapsible" data-collapsible="expandable">
<li class="">
<div class="collapsible-header active"><b>Instagram Account No.1 Details</b></div>
<div class="collapsible-body" style="display: none; padding-top: 0px; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px;">
<div class="input-field col s12">
Username: <input id="acc1user" name="acc1user" type="text" class="validate" required>
Password: <input id="acc1pass" name="acc1pass" type="text" class="validate" required>Account No.1 Audience: <input id="acc1audi" name="acc1audi" type="text" class="validate" required>
Note: Your Login Credentials will be safe with us do not worry.
</div>
</div>
</li>
</ul>
</div></div>
</h1>';}

And similarly many more fields as above
#Order Meta Update code
/**
* Update the order meta with field value for Package 1
*/

add_action( 'woocommerce_checkout_update_order_meta',   'my_custom_checkout_field_update_order_meta' );

function my_custom_checkout_field_update_order_meta( $order_id ) {

//Username and Password for 1st Account of Instagram

if ( ! empty( $_POST['acc1user'] ) ) {
update_post_meta( $order_id, 'Username1', sanitize_text_field(     $_POST['acc1user'] ) );
}

if ( ! empty( $_POST['acc1pass'] ) ) {
update_post_meta( $order_id, 'Password1', sanitize_text_field(     $_POST['acc1pass'] ) );
}

if ( ! empty( $_POST['acc1audi'] ) ) {
update_post_meta( $order_id, 'Account No.1 Audience', sanitize_text_field( $_POST['acc1audi'] ) );
}

if ( ! empty( $_POST['acc2user'] ) ) {
update_post_meta( $order_id, 'Username2', sanitize_text_field( $_POST['acc2user'] ) );
}

if ( ! empty( $_POST['acc2pass'] ) ) {
update_post_meta( $order_id, 'Password2', sanitize_text_field( $_POST['acc2pass'] ) );
}

if ( ! empty( $_POST['acc2audi'] ) ) {
update_post_meta( $order_id, 'Account No.1]2 Audience', sanitize_text_field( $_POST['acc2audi'] ) );
}

if ( ! empty( $_POST['acc3user'] ) ) {
update_post_meta( $order_id, 'Username3', sanitize_text_field( $_POST['acc3user'] ) );
}

if ( ! empty( $_POST['acc3pass'] ) ) {
update_post_meta( $order_id, 'Password3', sanitize_text_field( $_POST['acc3pass'] ) );
}

if ( ! empty( $_POST['acc3audi'] ) ) {
update_post_meta( $order_id, 'Account No.3 Audience', sanitize_text_field( $_POST['acc3audi'] ) );
}

if ( ! empty( $_POST['acc4user'] ) ) {
update_post_meta( $order_id, 'Username4', sanitize_text_field( $_POST['acc4user'] ) );
}

if ( ! empty( $_POST['acc4pass'] ) ) {
update_post_meta( $order_id, 'Password4', sanitize_text_field( $_POST['acc4pass'] ) );
}

if ( ! empty( $_POST['acc4audi'] ) ) {
update_post_meta( $order_id, 'Account No.4 Audience', sanitize_text_field( $_POST['acc4audi'] ) );
}

if ( ! empty( $_POST['acc5user'] ) ) {
update_post_meta( $order_id, 'Username5', sanitize_text_field( $_POST['acc5user'] ) );
}
if ( ! empty( $_POST['acc5pass'] ) ) {
update_post_meta( $order_id, 'Password5', sanitize_text_field( $_POST['acc5pass'] ) );
}

if ( ! empty( $_POST['acc5audi'] ) ) {
update_post_meta( $order_id, 'Account No.5 Audience', sanitize_text_field( $_POST['acc5audi'] ) );
}
if ( ! empty( $_POST['acc6user'] ) ) {
update_post_meta( $order_id, 'Username6', sanitize_text_field( $_POST['acc6user'] ) );
}
if ( ! empty( $_POST['acc6pass'] ) ) {
update_post_meta( $order_id, 'Password6', sanitize_text_field( $_POST['acc6pass'] ) );
}
}

включая мета-заказы в коде электронной почты

/**
* 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;
}

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector