{"id":72408,"date":"2020-02-15T09:54:54","date_gmt":"2020-02-15T07:54:54","guid":{"rendered":"https:\/\/www.drakauskas.lt\/blog\/?p=72408"},"modified":"2026-08-05T16:49:36","modified_gmt":"2026-08-05T13:49:36","slug":"add-custom-field-value-to-new-order-table-in-mail-message-only-for-admin","status":"publish","type":"post","link":"https:\/\/www.drakauskas.lt\/blog\/en\/add-custom-field-value-to-new-order-table-in-mail-message-only-for-admin\/","title":{"rendered":"Add information to table of new order mail message only for admin of WooCommerce"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To add information for message of new order only for admin. This code snippet is for funtions.php file, sets global variable about info of mail message, and adds a custom info to table cell of new order, if the mail message is for admin of WooCommerce . <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function email_order_id_as_a_global($order, \n                            $sent_to_admin, $plain_text, $email)\n{\n    $GLOBALS['email_data'] = array(\u2018sent_to_admin' => $sent_to_admin, \n                                            'email_id' => $email->id);\n}\n\nadd_action(\u2018woocommerce_email_before_order_table', \n                                    'email_order_id_as_a_global', 1, 4);\n\nfunction your_order_item_meta_start( $item_id, \n                                        $item, $order, $plain_text ) {\n\n$refNameGlobalsVar = $GLOBALS['email_data'];\nif (($refNameGlobalsVar[\u2018sent_to_admin']) &amp;&amp; \n                        ($refNameGlobalsVar['email_id'] == \u2018new_order'))\n    {\n       echo \"Custom field name: \" . ' Custom information to table cell';\n    }\n}\n\nadd_action( \u2018woocommerce_order_item_meta_end', 'your_order_item_meta_start',\n                                                                     20, 4 );<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To add information for message of new order only for admin. This code snippet is for funtions.php file, sets global variable about info of mail message, and adds a custom info to table cell of new order, if the mail message is for admin of WooCommerce .<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[237],"tags":[434,292,258],"class_list":["post-72408","post","type-post","status-publish","format-standard","hentry","category-wordpress-en","tag-admin-mail-message-en","tag-new-order-mail-message-en","tag-woocommerce-en"],"_links":{"self":[{"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/posts\/72408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/comments?post=72408"}],"version-history":[{"count":11,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/posts\/72408\/revisions"}],"predecessor-version":[{"id":72422,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/posts\/72408\/revisions\/72422"}],"wp:attachment":[{"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/media?parent=72408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/categories?post=72408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.drakauskas.lt\/blog\/wp-json\/wp\/v2\/tags?post=72408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}