简体   繁体   中英

Remove order details from WooCommerce processing order email notification

I am trying to remove info above the table about order from processing order email in woocommerce. In customer-processing-order.php i found this hook:

/*
 * @hooked WC_Emails::order_details() Shows the order details table.
 * @hooked WC_Structured_Data::generate_order_data() Generates structured data.
 * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
 * @since 2.5.0
 */
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );

How to remove the first hooked function from processing order email notification (to get blank order info I suppose) ?

You can use the following to remove order details from WooCommerce processing email notification sent to customer:

add_action( 'woocommerce_email_order_details', 'action_email_order_details', 2, 4 );
function action_email_order_details( $order, $sent_to_admin, $plain_text, $email ) {
    // Targeting "processing" order email notification sent to customer.
    if ( 'customer_processing_order' === $email->id ) {
        remove_action( 'woocommerce_email_order_details', array( WC()->mailer(), 'order_details' ) );
    }
}

Code goes in functions.php file of the active child theme (or active theme). Tested and works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM