{"id":1020,"date":"2024-05-25T10:00:56","date_gmt":"2024-05-25T10:00:56","guid":{"rendered":"https:\/\/www.appfinz.com\/blogs\/?p=1020"},"modified":"2025-05-15T05:02:42","modified_gmt":"2025-05-15T05:02:42","slug":"customizing-footer-text-email-notiications-based-on-user-role-in-woocommerce","status":"publish","type":"post","link":"https:\/\/www.appfinz.com\/blogs\/customizing-footer-text-email-notiications-based-on-user-role-in-woocommerce\/","title":{"rendered":"Customizing footer text email notiications based on user role in Woocommerce"},"content":{"rendered":"\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text\/x-php&quot;,&quot;theme&quot;:&quot;midnight&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;PHP&quot;,&quot;language&quot;:&quot;PHP&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;php&quot;}\">\/\/ Setting the Order ID as a global variable\nadd_action('woocommerce_email_before_order_table', 'email_order_id_as_a_global', 1, 4);\nfunction email_order_id_as_a_global($order, $sent_to_admin, $plain_text, $email){\n    $GLOBALS['order_id_str'] = $order-&gt;get_id();\n}\n\n\/\/ Conditionally customizing footer email text\nadd_action( 'woocommerce_email_footer_text', 'custom_email_footer_text', 10, 1 );\nfunction custom_email_footer_text( $get_option ){\n\n    \/\/ Getting the email Order ID global variable\n    $refNameGlobalsVar = $GLOBALS;\n    $order_id = $refNameGlobalsVar['order_id_str'];\n\n    \/\/ If empty email Order ID we exit\n    if( empty($order_id) ) return;\n\n    \/\/Get the customer ID\n    $user_id = get_post_meta( $order_id, '_customer_user', true );\n\n    \/\/ Get the user data\n    $user_data = get_userdata( $user_id );\n\n    if ( in_array( 'wholesale_customer', $user_data-&gt;roles )  ) {\n         $get_option = 'Store 1';\n    } else {\n         $get_option = 'Store 2';\n    }\n\n    return $get_option;\n}<\/pre><\/div>\n\n\n\n<p><em>Code goes in function.php file of the active child theme (or active theme).<\/em><\/p>\n\n\n\n<p>Tested and works. It should also work for you.<\/p>\n\n\n\n<p>If you\u2019re planning to revamp your online presence, don\u2019t miss exploring our\u00a0<a href=\"https:\/\/www.appfinz.com\/website-designing-company-in-delhi\"><strong>website designing services<\/strong><\/a>\u00a0and custom\u00a0<strong><a href=\"https:\/\/www.appfinz.com\/website-development-company-in-delhi\">website development<\/a><\/strong>\u00a0solutions tailored to your business needs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Code goes in function.php file of the active child theme (or active theme). Tested and<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[145],"tags":[],"class_list":["post-1020","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/www.appfinz.com\/blogs\/wp-json\/wp\/v2\/posts\/1020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appfinz.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appfinz.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appfinz.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appfinz.com\/blogs\/wp-json\/wp\/v2\/comments?post=1020"}],"version-history":[{"count":2,"href":"https:\/\/www.appfinz.com\/blogs\/wp-json\/wp\/v2\/posts\/1020\/revisions"}],"predecessor-version":[{"id":1368,"href":"https:\/\/www.appfinz.com\/blogs\/wp-json\/wp\/v2\/posts\/1020\/revisions\/1368"}],"wp:attachment":[{"href":"https:\/\/www.appfinz.com\/blogs\/wp-json\/wp\/v2\/media?parent=1020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appfinz.com\/blogs\/wp-json\/wp\/v2\/categories?post=1020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appfinz.com\/blogs\/wp-json\/wp\/v2\/tags?post=1020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}