Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Customize WooCommerce Email Content Based on Payment Method and Shipping Method?

Different payment methods have different processing times or requirements. The same applies to shipping methods as well. So, this code will help you to send a custom message to email notifications based on the customer-chosen shipping and payment methods for all orders that gets into completed order status.

add_action( 'woocommerce_email_order_details', 'ts_completed_order_email_instructions', 10, 4 );
function ts_completed_order_email_instructions( $order, $sent_to_admin, $plain_text, $email ) {
    // Only for "Customer Completed Order" email notification
    if( 'customer_completed_order' != $email->id ) return;

    // Check if the order uses Local Pickup shipping method
    if ( $order->has_shipping_method( 'local_pickup' ) ) {
        // Determine the payment method and display custom text accordingly
        if ( 'cod' == $order->get_payment_method() ) {
            echo '<p>' . __("Thank you for choosing Cash on Delivery!") . '</p>';
        } elseif ( 'bacs' == $order->get_payment_method() ) {
            echo '<p>' . __("Your order with Bank Transfer payment and Local Pickup is confirmed") . '</p>';
        } else {
            echo '<p>' . __("Thank you for choosing Local Pickup which is currently on hold. We appreciate your patience. If you have any questions, please contact our customer support. Thank you!") . '</p>';
        }
    }
}

Output

As per the conditions specified in the code, if the customer selects the shipping method ‘local pickup’ and the payment method as ‘Cash on Delivery’, then the following custom message is sent to email notifications of completed orders.

How to Customize WooCommerce Email Content Based on Payment Method and Shipping Method? - Tyche Softwares

If the customer selects the ‘Local pickup’ shipping method and chooses ‘Bacs’ as the payment method, the email notification will display the custom message below.

How to Customize WooCommerce Email Content Based on Payment Method and Shipping Method? - Tyche Softwares

If the customer selects the ‘local pickup’ shipping method and chooses any payment method other than ‘bacs’ or ‘cod,’ the following custom message will be displayed.

How to Customize WooCommerce Email Content Based on Payment Method and Shipping Method? - Tyche Softwares

Similar to the above custom message, you can also send a message for on hold status email for a specific shipping method in WooCommerce.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x