//Add coupon code to customer order email (specific to zero dollar discount)
add_filter( 'woocommerce_get_order_item_totals', 'add_coupons_codes_line_to_order_totals_lines', 10, 3 );
function add_coupons_codes_line_to_order_totals_lines( $total_rows, $order, $tax_display ) {
    $has_used_coupons = sizeof( $order->get_used_coupons() ) > 0 ? true : false;

    // Exit if there is no coupons applied
    if( ! $has_used_coupons )
        return $total_rows;

    $new_total_rows  = []; // Initializing
    $applied_coupons = $order->get_used_coupons(); // Get applied coupons

    foreach($total_rows as $key => $total ){
        $new_total_rows[$key] = $total;

        
        // Adding the discount line for orders with applied coupons and zero discount amount
        if( ! isset($total_rows['discount']) && $key === 'shipping' ) {
	        foreach( $order->get_used_coupons() as $coupon) {
            $coupon = strtoupper($coupon);
	        $coupon_code = '<strong>Coupon Code:</strong> '. $coupon;
	        $coupon_detail = get_page_by_title( $coupon, OBJECT, 'shop_coupon' );
        
            $new_total_rows['coupon_codes'] = array(
                'label' => $coupon_code,
                'value' => $coupon_detail->post_excerpt,
            );
        }
        }
    }

    return $new_total_rows;
}