Woocommerce wordimpress_checkout_field_order_meta_keys 格式展示

Woocommerce wordimpress_checkout_field_order_meta_keys format display

我想格式化我在电子邮件中的显示,而不是像这样显示:

例如:

Label 1: hello
Label 2: remote
Label 3: control

我想这样显示。

hello remote control

谢谢,

下面是我的代码:

add_filter( 'woocommerce_email_order_meta_keys', 'book_checkout_field_order_meta_keys' );

function book_checkout_field_order_meta_keys( $keys ) {

    $book = book_is_conditional_product_in_cart( 473 );

    //Only if book in cart
    if ( $book === true ) {

        $keys[] = 'Label 1';
        $keys[] = 'Label 2';
        $keys[] = 'Label 3';
    }

    return $keys;
}

如果您需要对显示进行更多控制,您可以通过挂钩添加数据,而不是将其列在元键中。这是我在电子邮件中打印某些元键的示例:

function kia_display_email_order_meta( $order, $sent_to_admin, $plain_text ) {
    $some_field = get_post_meta( $order->id, '_some_field', true ),
    $another_field = get_post_meta( $order->id, '_another_field', true ),
    if( $plain_text ){
        echo 'The value for some field is ' . $some_field . ' while the value of another field is ' . $another_field;
    } else {
        echo '<p>The value for <strong>some field</strong> is ' . $some_field. ' while the value of <strong>another field</strong> is ' . $another_field;</p>;
    }
}
add_action('woocommerce_email_customer_details', 'kia_display_email_order_meta', 30, 3 );