Woocommerce Display Custom Field value on the Email [Custom Field Display 3]
/**
* Display field value on the Email..
* source https://rudrastyh.com/woocommerce/order-meta-in-emails.html
* PHP Custom Feild Value
* @param $order_obj Order Object
* @param $sent_to_admin If this email is for administrator or for a customer
* @param $plain_text HTML or Plain text (can be configured in WooCommerce > Settings > Emails)
*
*/
add_action( 'woocommerce_email_order_meta', 'misha_add_email_order_meta', 10, 3 );
function misha_add_email_order_meta( $order_obj, $sent_to_admin, $plain_text ){
// ok, if it is the gift order, get all the other fields
$gift_wrap = get_post_meta( $order_obj->get_order_number(), 'My Field', true );
// you shouldn't have to worry about inline styles, WooCommerce adds them itself depending on the theme you use
echo '<h2>Store Location</h2>
<ul>
<li><strong>Your Store Location is:</strong> ' . $gift_wrap . '</li>
</ul>';
}
Are there any code examples left?
New code examples in category PHP
-
PHP 2022-03-27 22:40:03 index:of curiosa 2019 mp4
-
PHP 2022-03-27 22:35:13 Dijkstra’s algorithm php
-
PHP 2022-03-27 22:35:12 get_declared_classes
-
PHP 2022-03-27 22:30:23 php move index of a value to first position in array
-
PHP 2022-03-27 22:25:01 wordpress get_date
-
PHP 2022-03-27 21:30:38 php shorten string with dots
-
PHP 2022-03-27 21:10:46 php header 500
-
PHP 2022-03-27 21:05:06 laravel schedule run
-
PHP 2022-03-27 20:25:12 Get page title, excerpt or content by id
-
PHP 2022-03-27 20:00:27 php convert date from dd/mm/yyyy to yyyy-mm-dd