Franky
Franky

Reputation: 1

remove shipping and billing from woocommerce email

I want to remove the billing address and shipping address from the admin-new-order.php. I already have a duplicate of it in my theme. I was able to remove the email and phone number, but I just cant remove the billing and shipping.

To remove the email and phone I did this

    add_filter( 'woocommerce_email_customer_details_fields', 'custom_woocommerce_email_customer_details_fields' );    
function custom_woocommerce_email_customer_details_fields( $totals ) {
      unset( 
             $totals['billing_email'],
             $totals['billing_phone']
            );
           return $totals;   
         }

I know that if I completely removed:

 do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );

it would remove everything, but I can't do that because I need the notes, and delivery times (from a plugin) that displays there. If I delete the whole thing then it deletes everything.

I've tried

unset($totals['billing_first_name']);

And so many variations of this but it doesn't work.

enter image description here

Upvotes: 0

Views: 8552

Answers (1)

Ankur Bhadania
Ankur Bhadania

Reputation: 4158

In all email templates you have below do action hook. WC_Emails::email_address() this function code is used for add billing and shipping details in mails.

/**
 * @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 );

For remove the billing and shipping detail from mail put bellow function in your function.php file

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

Upvotes: 5

Related Questions