3

I have been searching but can't find any info on this.

I’d like to "text-align:center" the header text in the Order email sent to admin.

When I inspect the email element in my browser and change text-align:left to "center" the header text moves to where i want.

style='color:#ffffff;display:block;font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;font-size:30px;font-weight:300;line-height:150%;margin:0;padding:36px 48px;text-align:left'

regards maximoau

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
maximoau
  • 49
  • 4

1 Answers1

1

Previously the mail looked like.

enter image description here

In order to add styling to the headers of the order emails you can use the following code.

add_action('woocommerce_email_header', 'add_css_to_email');
function add_css_to_email() {
echo '
<style type="text/css">
h1 {
  text-align: center !important;
}
</style>
';
}

This code should be coded in functions.php of the theme or your custom plugin. For coding in theme its better to first create and use a child theme, code in its functions.php so that when that theme updates your code wont be overwritten.

After adding this code correctly in theme's/child theme's functions.php the output was -

enter image description here

Using the code in this answer you can give any styling to the header of the email. Note that this styling will even be applied to the mails which are sent on "new customer registration", "Order Complete" and others.

Domain
  • 11,562
  • 3
  • 23
  • 44
  • Hi WisdmLabs, Thank you for taking the time to show me this. I originally went and made a change in the h1 of the email-styles.php to do this but your way is elegant, not like my hack. Thanks again and I am looking forward for your generous time and help in the future. – maximoau May 29 '15 at 01:38
  • Hi, Welcome, we are happy to help and appreciate your appreciation for our efforts. You can mark a vote or mark this answer as correct if it worked for you. – Domain May 29 '15 at 05:57