Reputation: 3
I want to format my display in email, not display like this:
Ex:
Label 1: hello
Label 2: remote
Label 3: control
I want to display it likes this.
hello remote control
Thanks,
Here is my code below:
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;
}
Upvotes: 0
Views: 77
Reputation: 26329
If you need more control over the display you can add the data via a hook instead of listing it in the meta keys. Here is my example for printing certain meta keys in emails:
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 );
Upvotes: 1