In order to send Exception email notifications to only admin, Kindly activate Exception shipment status notifications for customers, after enabling TrackShip for WooCommerce can trigger an email when the Shipment status changes to an exception.
To prevent sending this email to your customers, use the following code snippet into the function.php file of your theme.
You can also find code snippet from gist.
<?php
// This code snippet adds a filter to control email recipients for a specific status.
// Use the 'add_multiple_emails_to_shipment_email' filter hook to modify recipient email addresses.
add_filter( 'add_multiple_emails_to_shipment_email', 'add_email_address', 10, 2 );
function add_email_address( $email_to, $new_status ) {
// Check if the status is 'exception' to determine whether to send the email to the admin only.
if ( 'exception' == $new_status ) {
// Override the recipient email array to send the exception email to the admin.
$email_to = ['[email protected]']; // Replace with the admin's email address.
}
return $email_to; // Return the modified or original email recipient array.
}
Please note: Incorrect editing of the functions.php
file can cause your WordPress site to crash, leading to potential downtime and data loss.
If you're uncomfortable modifying the functions.php
file directly, consider using a dedicated code snippets plugin, or seek assistance from a professional developer.