Removing customer details and addresses from email notification templates

I am working on a theme created for woocommerce created by some other German developer. I created my child theme and used the functions.php child theme to make changes to the functionality of the website.

When a customer orders a product, he receives an email with an order table, customer information and billing address and customer delivery. I want to delete everything under the table and add my own text (customer information + billing, sending and receiving addresses).

I added my own text right below the order table in the email that is sent to the customer, however I cannot delete the information that appears by default below my custom added text. I found a hook responsible for fetching and showing that data woocommerce_email_order_meta, but I don’t know how to delete it or prevent it from executing. I do not want to make changes to the template files, I want to do all this by intercepting.

So far I have tried to do this as follows:

remove_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email ); 

I followed the link: Delete the order information section from the email template in woocommerce and tried the following code: but it didn’t work >.

function so_39251827_remove_order_details( $order, $sent_to_admin, $plain_text, $email ){
    $mailer = WC()->mailer(); // get the instance of the WC_Emails class
    remove_action( 'woocommerce_email_order_details', array( $mailer, 'order_details' ), 10, 4 );
}
add_action( 'woocommerce_email_order_details', 'so_39251827_remove_order_details', 5, 4 );

How can i achieve this?

thank

+4
1

. :

/**
 * @hooked WC_Emails::customer_details() Shows customer details
 * @hooked WC_Emails::email_address() Shows email address
 */
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );

WooCommerce , , .

:

function removing_customer_details_in_emails( $order, $sent_to_admin, $plain_text, $email ){
    $mailer = WC()->mailer();
    remove_action( 'woocommerce_email_customer_details', array( $mailer, 'customer_details' ), 10, 4 );
    remove_action( 'woocommerce_email_customer_details', array( $mailer, 'email_addresses' ), 20, 4 );
}
add_action( 'woocommerce_email_customer_details', 'removing_customer_details_in_emails', 5, 4 );

function.php ( ), .

.


:

+8

Source: https://habr.com/ru/post/1656063/


All Articles