To send Shipment status email notifications to multiple recipients based on specific statuses or for all shipment statuses, integrate the following code snippet into your theme's function.php file.
You can also find code snippet from gist.
<?php
// This code snippet customizes email recipients based on a specific status.
// To modify recipient email addresses, use the 'add_multiple_emails_to_shipment_email' filter hook.
add_filter( 'add_multiple_emails_to_shipment_email', 'customize_email_recipients', 10, 2 );
function customize_email_recipients( $email_to, $new_status ) {
// Check if the status is 'exception' to send the email to additional recipient(s). You can change condition as per your required
// Remove the if conditions for all shipment status emails will be sent to new recipients.
if ( 'exception' == $new_status ) {
$email_to[] = '[email protected]'; // Replace with the admin's email.
}
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.