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

How to Customize the Subject of WooCommerce On Hold Order Email ?

Do you want to change the generic emails sent to on-hold orders, especially when a coupon is used with a personalized note in the subject line? You can do it with WooCommerce customization!

By adding details about the coupon used right into the subject line of the ‘On Hold Order ‘ email, you’re giving customers a clear picture of the coupons used, and their order progress, making their shopping experience even more delightful. Let’s see how to achieve this in WooCommerce.

Solution: Customize the Subject of WooCommerce On Hold Order Email

The code customizes the subject line of the ‘On Hold Order’ email specifically for orders that are on hold. It dynamically includes details about any applied coupons in the subject line to provide customers with relevant information regarding the discounts applied in the order.

add_filter( 'woocommerce_email_subject_customer_on_hold_order', 'ts_custom_email_subject_on_hold', 20, 2 );

function ts_custom_email_subject_on_hold( $formated_subject, $order ){
    // Get applied coupons
    $applied_coupons = $order->get_used_coupons();
    
    // Check if coupons are applied
    if ( $applied_coupons ) {
        // Retrieve the first applied coupon
        $applied_coupon = reset( $applied_coupons );
        
        // Build the subject line dynamically
        return sprintf( __('Coupon "%s" has been applied', 'woocommerce' ), $applied_coupon );
    }
    
    // If no coupons applied, return the default subject
    return $formated_subject;
}

Output

The code dynamically updates the subject line of the ‘On-Hold Order’ email to include details about the applied coupon when an order is on hold.This provides clarity and reassurance about your order status and applied discounts.

How to Customize the Subject of WooCommerce On Hold Order Email ? - Tyche Softwares

Looking to customize emails for other custom order statuses that you have? Check out our guide on sending customized emails for custom order statuses 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