Search code examples
phpwordpresswoocommercehook-woocommerceemail-notifications

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)?


Solution

  • 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.