woocommerce display custom field value on the email 5bcustom field display 3 5d

Solutions on MaxInterview for woocommerce display custom field value on the email 5bcustom field display 3 5d by the best coders in the world

showing results for - "woocommerce display custom field value on the email 5bcustom field display 3 5d"
Louisa
10 Jan 2018
1/**
2 * Display field value on the Email..
3 * source https://rudrastyh.com/woocommerce/order-meta-in-emails.html
4 * PHP Custom Feild Value
5 * @param $order_obj Order Object
6 * @param $sent_to_admin If this email is for administrator or for a customer
7 * @param $plain_text HTML or Plain text (can be configured in WooCommerce > Settings > Emails) 
8 * 
9 */
10add_action( 'woocommerce_email_order_meta', 'misha_add_email_order_meta', 10, 3 );
11function misha_add_email_order_meta( $order_obj, $sent_to_admin, $plain_text ){
12 
13  // ok, if it is the gift order, get all the other fields
14  $gift_wrap = get_post_meta( $order_obj->get_order_number(), 'My Field', true );
15 
16
17 
18    // you shouldn't have to worry about inline styles, WooCommerce adds them itself depending on the theme you use
19    echo '<h2>Store Location</h2>
20    <ul>
21    <li><strong>Your Store Location is:</strong> ' . $gift_wrap . '</li>
22    </ul>';
23
24}