I hired a contractor to help me with my site a few years ago when I didn’t have the coding experience that I do today. The contractor ended up making new templates for almost every email, and they are all out of date. I started making updates to them when I realized I should just be making the custom changes in the functions.php page so I don’t have to go through updating a billion templates each time WooCommerce makes an update.
I’m taking baby steps here and the first thing I’d like to do is for the admin-new-order.php email template.
Towards the top of template there is a section that has this information in it.
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php /* translators: %s: Customer billing full name */ ?>
<p><?php printf( esc_html__( 'You’ve received the following order from %s:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
What I’d like to do is add something to my functions file so that I can tweak this code block (I need it to be shipping instead of billing name). So I was thinking something like this.
add_filter('woocommerce_email_header', 'filter_heading_new_order');
function filter_heading_new_order($example) {
$example = <?php /* translators: %s: Customer billing full name */ ?>
<p><?php printf( esc_html__( 'You’ve received the following order from %s:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
return $example;
}
Disregard syntax above I merely copy/pasted that in to give a feel for what I’m looking for. Regardless of if I were to fix the syntax above it doesn’t work. I still see the same stuff in the email template.
My question is how can I use a hook and or filter to replace some of the content of the email template? Specifically the "You’ve received the following order from UserXYZ:" part.
Thanks!