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
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 );
Related
I'm looking for the easiest way to remove this tracking number tablefrom a transactional email in woocommerce.
Image attached to show what I mean.
I understand it's pulled from a function, but I don't know how to edit it without destroying the rest of the table, which I need to stay as is.
I'm not a coder, but I can follow instructions. Could tell me where I need to go and which parts to change. I could probably find my way into the function file, but I don't know how to edit it safely or what to delete/change.
<?php
/*
* #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 );
/*
* #hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
/*
* #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 );
/*
* #hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );
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.
I have seen this snippet which removes from all customer emails, however I'm wondering how to remove the downloads section from the Woocommerce email: Order Refunded.
add_action( 'woocommerce_email', 'remove_order_downloads_from_emails', 10, 1 );
function remove_order_downloads_from_emails( $emails ){
remove_action( 'woocommerce_email_order_details', array( $emails, 'order_downloads' ), 10 );
}
Any help much appreciated.
The following code will remove the downloads table section from Refunded order email notification:
add_action( 'woocommerce_email_order_details', 'remove_downloads_section_from_refunded_order_emails', 1, 4 );
function remove_downloads_section_from_refunded_order_emails( $order, $sent_to_admin, $plain_text, $email ){
if( $email->id === 'customer_refunded_order' )
remove_action( 'woocommerce_email_order_details', array( WC()->mailer(), 'order_downloads' ), 10 );
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
I am trying to remove the order details table from every completed order mail:
I have tried something like this:
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 );
It actually did remove the table but I am thinking the hook is removed from entirely all mail notifications, that's both the admin and customer mail template.
Can somebody help me on how to remove it from only completed order mail sent to customers?
copy this email template
\wp-content\plugins\woocommerce\templates\emails\customer-completed-order.php
to your theme here
\wp-content[theme_folder]\woocommerce\emails\customer-completed-order.php
and comment our this line
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
that should remove the order details table just from the customer email.
I am working on a theme created for woocommerce, built by some other German developer. I have created my child theme and using child theme's functions.php to make changes to functionality of the website.
When a customer orders a product, he receives an email with order table, customer information and billing address and customer shipping.
I want to remove everything below the table and add my own text (customer info + billing, shipping and pick up address as well).
I have added my own text right below the order table in email that goes to customer, however I am unable to delete the information that shows by default below my custom added text. I found the hook responsible for fetching and showing that data is woocommerce_email_order_meta, but I don't know how to remove it or prevent it from executing. I don't want to make changes in the template files, I want to do it all by hooks.
So far I have tried doing it like this:
remove_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
I followed the link: Delete order info section from email template in woocommerce and tried the following code as well, but 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?
Explanations - In all email notification templates you have this:
/**
* #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 );
After some research in WooCommerce core files and some test, I have removed successfully the customer details, the billing and shipping address from notification emails as you wished.
Here is the code:
add_action( 'woocommerce_email_customer_details', 'removing_customer_details_in_emails', 5, 4 );
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 );
remove_action( 'woocommerce_email_customer_details', array( $mailer, 'email_addresses' ), 20 );
}
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested and fully functional.
References :
Class WC_Emails customer_details() method
Class WC_Emails email_addresses() method