Looking to customize the shipping notices sent to email notifications? This code provides a clear and informative message to the customer when their order status is ‘on hold’ and the “Free Shipping” method is chosen. You can customize the message to fit your specific needs.
add_action ('woocommerce_email_order_details', 'ts_custom_email_notification_for_shipping', 5, 4); function ts_custom_email_notification_for_shipping( $order, $sent_to_admin, $plain_text, $email ){ // Only for "On hold" email notification and "Free Shipping" Shipping Method if ( 'customer_on_hold_order' == $email->id && $order->has_shipping_method('free_shipping') ){ $order_id = $order->get_id(); // The Order ID // Your shipping notice message $shipping_notice = " <h2>Important Shipping Notice</h2> <p>Dear valued customer,</p> <p>We wanted to inform you that your order (#{$order_id}) is currently on hold. This may be due to a specific requirement or additional information needed to process the shipment.</p> <p>Please check your order details, and if there are any issues or if further information is required, our customer support team will reach out to you shortly.</p> <p>Thank you for your understanding.</p> "; // Output the shipping notice echo $shipping_notice; } }
Output
When the ‘customer_on_hold_order’ email is triggered and the order has the ‘Free Shipping’ method, it generates a personalized shipping notice as shown below.
One extra functionality that can be added to email notifications is customizing the address shown in emails. You can also hide shipping address based on shipping method in email notifications.