The "woocommerce_email_customer_details" action contains billing address and shipping address data. All I need is the shipping address.
How can I achieve this goal? Below is my current "New Order" email plain text template (admin-new-order.php)
/*Admin new order email (plain text)*/ defined( 'ABSPATH' ) || exit; do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email ); if ( $additional_content ) { echo esc_html( wp_strip_all_tags( wptexturize( $additional_content ) ) ); }
For HTML email:
If you use this code, it will remove billing and shipping information from the required email notifications. This is because it ensures that the related template files are not loaded:
However, since you only want to partially hide/not show the output of the related template file (/emails/email-addresses.php) a different approach will be required强>.
This can be done by adapting the /emails/email-addresses.php template file to your needs. This template can be overridden by copying it yourtheme/woocommerce/emails/email-addresses.php
Note: Since you only want to apply this to specific email notifications, you will need to use
$email->id
. Since this is not passed to the relevant template file by default, a workaround is required.How to pass "$email" to the WooCommerce email template file if it is not available by defaultThis is described in Reply Codes.
So to answer your question:
Step 1)Add in the functions.php
file of the active child theme (or active theme)Step 2) In the /emails/email-addresses.php template file, @version 5.6.0
Replace lines 18 - 20
and
and
Replace lines 28 - 40
and
For plain text email:
Step 1)Add in the functions.php
file of the active child theme (or active theme)Step 2) In the /emails/plain/email-addresses.php template file, @version 5.6.0
Replace lines 20 - 29
and