Php WooCommerce:添加带有自定义电子邮件通知的自定义订单状态

Php WooCommerce:添加带有自定义电子邮件通知的自定义订单状态,php,wordpress,woocommerce,hook-woocommerce,orders,Php,Wordpress,Woocommerce,Hook Woocommerce,Orders,使用应答代码,我已经能够收到一个自定义状态的电子邮件通知,但是我无法了解如何才能发送两个自定义状态的电子邮件通知 请参见下面的示例代码&我尝试过的用于多个自定义状态电子邮件通知的代码。我还包括了我的完整代码,它显示了创建多个状态的整个过程 希望在这个快速解决方案上得到一些帮助 另外,对于电子邮件正文-是否有可能通过此代码更改处理订单内容,而无需创建新的电子邮件模板 工作-单个自定义状态电子邮件通知“已发货” 尝试/不工作-两种自定义状态的电子邮件通知 // Adding action for '

使用应答代码,我已经能够收到一个自定义状态的电子邮件通知,但是我无法了解如何才能发送两个自定义状态的电子邮件通知

请参见下面的示例代码&我尝试过的用于多个自定义状态电子邮件通知的代码。我还包括了我的完整代码,它显示了创建多个状态的整个过程

希望在这个快速解决方案上得到一些帮助

另外,对于电子邮件正文-是否有可能通过此代码更改处理订单内容,而无需创建新的电子邮件模板

工作-单个自定义状态电子邮件通知“已发货”

尝试/不工作-两种自定义状态的电子邮件通知

// Adding action for 'awaiting-delivery'
add_filter( 'woocommerce_email_actions', 'custom_email_actions', 20, 1 );
function custom_email_actions( $action ) {
  $actions[] = 'woocommerce_order_status_wc-shipped';
  $actions[] = 'woocommerce_order_status_wc-readytocollect';
  return $actions;
}

add_action( 'woocommerce_order_status_wc-shipped', array( WC(), 'send_transactional_email' ), 10, 1 );
add_action( 'woocommerce_order_status_wc-readytocollect', array( WC(), 'send_transactional_email' ), 10, 1 );

// Sending an email notification when order gets a custom status
add_action('woocommerce_order_status_changed', 'custom_status_trigger_email_notification', 10, 4);
function custom_status_trigger_email_notification( $order_id, $from_status, $to_status, $order ) {
   $custom_statuses = array('Shipped', 'Ready to Collect'); // Here your custom statuses slugs

   if( in_array($to_status, $custom_statuses) ) {
       // Loop through each custom status
       foreach ( $custom_statuses as $custom_status ) {
           // Trigger an email notification when a order get a custom status
           if ( $custom_status === $to_status ) {
               WC()->mailer()->get_emails()['WC_Email_Customer_Processing_Order']->trigger( $order_id );
           }
       }
   }
}

// Customize email heading for your custom statuses email notifications
add_filter( 'woocommerce_email_heading_customer_processing_order', 'custom_email_heading_for_custom_order_status', 10, 2 );
function custom_email_heading_for_custom_order_status( $heading, $order ){
   // Here your custom statuses slugs / Heading texts pairs
   $custom_statuses = array(
       'Shipped'         => __('Planet Vape {order_number} has been Shipped!','woocommerce'),
       'Ready to Collect' => __('Planet Vape {order_number} is Ready to Collect!','woocommerce')
   );

   // Loop through each custom status / heading text pairs
   foreach ( $custom_statuses as $custom_status => $heading_text ) {
       // Change an email notification heading text when a order get a custom status
       if( $order->has_status( $custom_status ) ) {
           $email = WC()->mailer()->get_emails()['WC_Email_Customer_Processing_Order']; // Get the specific WC_emails object

           return $email->format_string( $heading_text );
       }
   }
   return $heading;
}

// Customize email subject for your custom statuses email notifications
add_filter( 'woocommerce_email_subject_customer_processing_order', 'custom_email_subject_for_custom_order_status', 10, 2 );
function custom_email_subject_for_custom_order_status( $subject, $order ){
   // Here your custom statuses slugs / Heading texts pairs
   $custom_statuses = array(
       'Shipped'         => __('Planet Vape {order_number} has been Shipped!','woocommerce'),
       'Ready to Collect' => __('Planet Vape {order_number} is Ready to Collect!','woocommerce')
   );

   // Loop through each custom status / subject text pairs
   foreach ( $custom_statuses as $custom_status => $subject_text ) {
       // Change an email notification heading text when a order get a custom status
       if( $order->has_status( $custom_status ) ) {
           $email = WC()->mailer()->get_emails()['WC_Email_Customer_Processing_Order']; // Get the specific WC_emails object

           return $email->format_string( $subject_text );
       }
   }
   return $subject;
}
单一自定义状态的工作邮件完整代码。 这显示了我使用批量操作和操作按钮添加自定义状态的完整过程-所有操作都正常

add_action('init', 'register_custom_order_statuses');
function register_custom_order_statuses() {
    register_post_status('wc-shipped ', array(
        'label' => __( 'Shipped', 'woocommerce' ),
        'public' => true,
        'exclude_from_search' => false,
        'show_in_admin_all_list' => true,
        'show_in_admin_status_list' => true,
        'label_count' => _n_noop('Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>')
    ));
    register_post_status('wc-readytocollect ', array(
        'label' => __( 'Ready to Collect', 'woocommerce' ),
        'public' => true,
        'exclude_from_search' => false,
        'show_in_admin_all_list' => true,
        'show_in_admin_status_list' => true,
        'label_count' => _n_noop('Ready to Collect <span class="count">(%s)</span>', 'Ready to Collect <span class="count">(%s)</span>')
    ));
}


// Add a custom order status to list of WC Order statuses
add_filter('wc_order_statuses', 'add_custom_order_statuses');
function add_custom_order_statuses($order_statuses) {
    $new_order_statuses = array();

    // add new order status before processing
    foreach ($order_statuses as $key => $status) {
        $new_order_statuses[$key] = $status;
        if ('wc-processing' === $key) {
            $new_order_statuses['wc-shipped'] = __('Shipped', 'woocommerce' );
            $new_order_statuses['wc-readytocollect'] = __('Ready to Collect', 'woocommerce' );
        }
    }
    return $new_order_statuses;
}


// Adding custom status 'awaiting-delivery' to admin order list bulk dropdown
add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 50, 1 );
function custom_dropdown_bulk_actions_shop_order( $actions ) {
    $new_actions = array();

    // add new order status before processing
    foreach ($actions as $key => $action) {
        if ('mark_processing' === $key)
            $new_actions['mark_shipped'] = __( 'Change status to shipped', 'woocommerce' );
            $new_actions['mark_readytocollect'] = __( 'Change status to Ready to Collect', 'woocommerce' );
            
        $new_actions[$key] = $action;
    }
    return $new_actions;
}

// Add a custom order status action button (for orders with "processing" status)
add_filter( 'woocommerce_admin_order_actions', 'add_custom_order_status_actions_button', 100, 2 );
function add_custom_order_status_actions_button( $actions, $order ) {
    // Display the button for all orders that have a 'processing', 'pending' or 'on-hold' status
    if ( $order->has_status( array( 'on-hold', 'processing', 'pending' ) ) ) {

        // The key slug defined for your action button
        $action_slug = 'shipped';

        // Set the action button
        $actions[$action_slug] = array(
            'url'       => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status='.$action_slug.'&order_id='.$order->get_id() ), 'woocommerce-mark-order-status' ),
            'name'      => __( 'Shipped', 'woocommerce' ),
            'action'    => $action_slug,
        );
    }
    return $actions;
}

// Set styling for custom order status action button icon and List icon
add_action( 'admin_head', 'add_custom_order_status_actions_button_css' );
function add_custom_order_status_actions_button_css() {
    $action_slug = "shipped"; // The key slug defined for your action button
    ?>
    <style>
        .wc-action-button-<?php echo $action_slug; ?>::after {
            font-family: woocommerce !important; content: "\e029" !important;
        }
    </style>
    <?php
}

add_filter( 'woocommerce_email_actions', 'filter_woocommerce_email_actions' );
function filter_woocommerce_email_actions( $actions ){
    $actions[] = 'woocommerce_order_status_wc-shipped';
    return $actions;
}

// Send Customer Processing Order email notification when order status get changed from "tree" to "processing"
add_action('woocommerce_order_status_changed', 'shipped_status_custom_notification', 10, 4);
function shipped_status_custom_notification( $order_id, $from_status, $to_status, $order ) {
    if(  'shipped' === $to_status ) {
        // The email notification type
        $email_key   = 'WC_Email_Customer_Processing_Order';

        // Get specific WC_emails object
        $email_obj = WC()->mailer()->get_emails()[$email_key];

        // Sending the customized email
        $email_obj->trigger( $order_id );
    }
}

// Customize email heading for this custom status email notification
add_filter( 'woocommerce_email_heading_customer_processing_order', 'email_heading_customer_shipped_order', 10, 2 );
function email_heading_customer_shipped_order( $heading, $order ){
    if( $order->has_status( 'shipped' ) ) {
        $email_key   = 'WC_Email_Customer_Processing_Order'; // The email notification type
        $email_obj   = WC()->mailer()->get_emails()[$email_key]; // Get specific WC_emails object
        $heading_txt = sprintf( __('Order #%s has been Shipped!', 'woocommerce'), '{order_number}' ); // New subject text

        return $email_obj->format_string( $heading_txt );
    }
    return $heading;
}

// Customize email subject for this custom status email notification
add_filter( 'woocommerce_email_subject_customer_processing_order', 'email_subject_customer_shipped_order', 10, 2 );
function email_subject_customer_shipped_order( $subject, $order ){
    if( $order->has_status( 'shipped' ) ) {
        $email_key   = 'WC_Email_Customer_Processing_Order'; // The email notification type
        $email_obj   = WC()->mailer()->get_emails()[$email_key]; // Get specific WC_emails object
        $subject_txt = sprintf( __('Your %s Order #%s has been Shipped!', 'woocommerce'), '{site_title}', '{order_number}' ); // New subject text

        return $email_obj->format_string( $subject_txt );
    }
    return $subject;
}
add_action('init','register_custom_order_status');
功能寄存器\自定义\订单\状态(){
注册后状态('wc-shipped',数组(
“标签”=>uuuuuuuuuuuuuuuu('Shipped'、'woocommerce'),
“public”=>正确,
“从搜索中排除”=>false,
“在\u管理\u所有\u列表中显示\u”=>true,
“在管理状态列表中显示”=>true,
“标签计数”=>\n\u noop(“已装运(%s)”,“已装运(%s)”)
));
注册后状态('wc-readytocollect',数组(
'label'=>\('Ready to Collect','woocommerce'),
“public”=>正确,
“从搜索中排除”=>false,
“在\u管理\u所有\u列表中显示\u”=>true,
“在管理状态列表中显示”=>true,
'label_count'=>'u n_noop('Ready to collection(%s)','Ready to collection(%s)'
));
}
//将自定义订单状态添加到WC订单状态列表
添加过滤器(“wc订单状态”、“添加自定义订单状态”);
功能添加自定义订单状态($order\U STATUS){
$new_order_status=array();
//处理前添加新订单状态
foreach($key=>$status的订单状态){
$new_order_status[$key]=$status;
if('wc-processing'==$key){
$new_order_statuses['wc-shipped']==uuu('shipped','woocommerce');
$new_order_statuses['wc-readytocollect']='Ready to Collect','woocommerce');
}
}
返回$new\u order\u状态;
}
//将自定义状态“等待交货”添加到“管理订单列表”批量下拉列表中
添加过滤器(“批量操作-编辑-店铺订单”,“自定义”下拉列表-批量操作-店铺订单”,50,1);
功能自定义\下拉菜单\批量\操作\车间\订单($actions){
$new_actions=array();
//处理前添加新订单状态
foreach($key=>$action的操作){
if('mark_processing'==$key)
$new_actions['mark_shipped']=uuu('Change status to shipped','woocommerce');
$new_actions['mark_readytocollect']=uuu('Change status to Ready to Collect','woocommerce');
$new_actions[$key]=$action;
}
返回$new_actions;
}
//添加自定义订单状态操作按钮(对于具有“处理”状态的订单)
添加过滤器('woocommerce\u admin\u order\u actions','add\u custom\u order\u status\u actions\u button',100,2);
功能添加\自定义\订单\状态\操作\按钮($actions,$order){
//显示具有“正在处理”、“挂起”或“保留”状态的所有订单的按钮
如果($order->has_status(数组('on hold','processing','pending')){
//为动作按钮定义的键段塞
$action_slug=‘已发货’;
//设置操作按钮
$actions[$action\u slug]=数组(
“url'=>wp\u nonce\u url(admin\u url('admin ajax.php?action=woocommerce\u mark\u order\u status&status='。$action\u slug.&order\u id='。$order->get\u id()),“woocommerce-mark-order-status=”,
“名称”=>uuuuuuuuuuuuuu('Shipped','woocommerce'),
“action”=>$action\u slug,
);
}
返回$actions;
}
//设置自定义订单状态操作按钮图标和列表图标的样式
添加操作('admin_head'、'add_custom_order_status_actions_button_css');
函数添加\自定义\订单\状态\操作\按钮\ css(){
$action\u slug=“shipped”;//为操作按钮定义的键slug
?>
.wc操作按钮-::之后{
字体系列:woocommerce!重要;内容:“\e029”!重要;
}

有一些错误…对于具有自定义电子邮件通知的多个订单状态,请使用以下完整代码(在删除所有相关代码之前删除):

//为商业订单启用自定义状态
添加操作(“初始化”、“注册自定义订单状态”);
功能寄存器\自定义\订单\状态(){
注册后状态('wc-shipped',数组(
“标签”=>uuuuuuuuuuuuuuuu('Shipped'、'woocommerce'),
“public”=>正确,
“从搜索中排除”=>false,
“在\u管理\u所有\u列表中显示\u”=>true,
“在管理状态列表中显示”=>true,
“标签计数”=>\n\u noop(“已装运(%s)”,“已装运(%s)”)
));
注册后状态('wc-readytocollect',数组(
'label'=>\('Ready to Collect','woocommerce'),
“public”=>正确,
“从搜索中排除”=>false,
“在\u管理\u所有\u列表中显示\u”=>true,
“在管理状态列表中显示”=>true,
'label_count'=>'u n_noop('Ready to collection(%s)','Ready to collection(%s)'
));
}
//将自定义订单状态添加到WC订单状态列表
添加过滤器(“wc订单状态”、“添加自定义订单状态”);
功能添加自定义订单状态($order\U STATUS){
$new_order_status=array();
//处理前添加新订单状态
foreach($key=>$status的订单状态){
$new_order_status[$key]=$status;
if('wc-processing'==$key){
$new_order_statuses['wc-shipped']==uuu('shipped','woocommerce');
$
add_action('init', 'register_custom_order_statuses');
function register_custom_order_statuses() {
    register_post_status('wc-shipped ', array(
        'label' => __( 'Shipped', 'woocommerce' ),
        'public' => true,
        'exclude_from_search' => false,
        'show_in_admin_all_list' => true,
        'show_in_admin_status_list' => true,
        'label_count' => _n_noop('Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>')
    ));
    register_post_status('wc-readytocollect ', array(
        'label' => __( 'Ready to Collect', 'woocommerce' ),
        'public' => true,
        'exclude_from_search' => false,
        'show_in_admin_all_list' => true,
        'show_in_admin_status_list' => true,
        'label_count' => _n_noop('Ready to Collect <span class="count">(%s)</span>', 'Ready to Collect <span class="count">(%s)</span>')
    ));
}


// Add a custom order status to list of WC Order statuses
add_filter('wc_order_statuses', 'add_custom_order_statuses');
function add_custom_order_statuses($order_statuses) {
    $new_order_statuses = array();

    // add new order status before processing
    foreach ($order_statuses as $key => $status) {
        $new_order_statuses[$key] = $status;
        if ('wc-processing' === $key) {
            $new_order_statuses['wc-shipped'] = __('Shipped', 'woocommerce' );
            $new_order_statuses['wc-readytocollect'] = __('Ready to Collect', 'woocommerce' );
        }
    }
    return $new_order_statuses;
}


// Adding custom status 'awaiting-delivery' to admin order list bulk dropdown
add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 50, 1 );
function custom_dropdown_bulk_actions_shop_order( $actions ) {
    $new_actions = array();

    // add new order status before processing
    foreach ($actions as $key => $action) {
        if ('mark_processing' === $key)
            $new_actions['mark_shipped'] = __( 'Change status to shipped', 'woocommerce' );
            $new_actions['mark_readytocollect'] = __( 'Change status to Ready to Collect', 'woocommerce' );
            
        $new_actions[$key] = $action;
    }
    return $new_actions;
}

// Add a custom order status action button (for orders with "processing" status)
add_filter( 'woocommerce_admin_order_actions', 'add_custom_order_status_actions_button', 100, 2 );
function add_custom_order_status_actions_button( $actions, $order ) {
    // Display the button for all orders that have a 'processing', 'pending' or 'on-hold' status
    if ( $order->has_status( array( 'on-hold', 'processing', 'pending' ) ) ) {

        // The key slug defined for your action button
        $action_slug = 'shipped';

        // Set the action button
        $actions[$action_slug] = array(
            'url'       => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status='.$action_slug.'&order_id='.$order->get_id() ), 'woocommerce-mark-order-status' ),
            'name'      => __( 'Shipped', 'woocommerce' ),
            'action'    => $action_slug,
        );
    }
    return $actions;
}

// Set styling for custom order status action button icon and List icon
add_action( 'admin_head', 'add_custom_order_status_actions_button_css' );
function add_custom_order_status_actions_button_css() {
    $action_slug = "shipped"; // The key slug defined for your action button
    ?>
    <style>
        .wc-action-button-<?php echo $action_slug; ?>::after {
            font-family: woocommerce !important; content: "\e029" !important;
        }
    </style>
    <?php
}

add_filter( 'woocommerce_email_actions', 'filter_woocommerce_email_actions' );
function filter_woocommerce_email_actions( $actions ){
    $actions[] = 'woocommerce_order_status_wc-shipped';
    return $actions;
}

// Send Customer Processing Order email notification when order status get changed from "tree" to "processing"
add_action('woocommerce_order_status_changed', 'shipped_status_custom_notification', 10, 4);
function shipped_status_custom_notification( $order_id, $from_status, $to_status, $order ) {
    if(  'shipped' === $to_status ) {
        // The email notification type
        $email_key   = 'WC_Email_Customer_Processing_Order';

        // Get specific WC_emails object
        $email_obj = WC()->mailer()->get_emails()[$email_key];

        // Sending the customized email
        $email_obj->trigger( $order_id );
    }
}

// Customize email heading for this custom status email notification
add_filter( 'woocommerce_email_heading_customer_processing_order', 'email_heading_customer_shipped_order', 10, 2 );
function email_heading_customer_shipped_order( $heading, $order ){
    if( $order->has_status( 'shipped' ) ) {
        $email_key   = 'WC_Email_Customer_Processing_Order'; // The email notification type
        $email_obj   = WC()->mailer()->get_emails()[$email_key]; // Get specific WC_emails object
        $heading_txt = sprintf( __('Order #%s has been Shipped!', 'woocommerce'), '{order_number}' ); // New subject text

        return $email_obj->format_string( $heading_txt );
    }
    return $heading;
}

// Customize email subject for this custom status email notification
add_filter( 'woocommerce_email_subject_customer_processing_order', 'email_subject_customer_shipped_order', 10, 2 );
function email_subject_customer_shipped_order( $subject, $order ){
    if( $order->has_status( 'shipped' ) ) {
        $email_key   = 'WC_Email_Customer_Processing_Order'; // The email notification type
        $email_obj   = WC()->mailer()->get_emails()[$email_key]; // Get specific WC_emails object
        $subject_txt = sprintf( __('Your %s Order #%s has been Shipped!', 'woocommerce'), '{site_title}', '{order_number}' ); // New subject text

        return $email_obj->format_string( $subject_txt );
    }
    return $subject;
}
// Enable custom statuses for WooCommerce Orders
add_action('init', 'register_custom_order_statuses');
function register_custom_order_statuses() {

    register_post_status('wc-shipped ', array(
        'label' => __( 'Shipped', 'woocommerce' ),
        'public' => true,
        'exclude_from_search' => false,
        'show_in_admin_all_list' => true,
        'show_in_admin_status_list' => true,
        'label_count' => _n_noop('Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>')
    ));

    register_post_status('wc-readytocollect ', array(
        'label' => __( 'Ready to Collect', 'woocommerce' ),
        'public' => true,
        'exclude_from_search' => false,
        'show_in_admin_all_list' => true,
        'show_in_admin_status_list' => true,
        'label_count' => _n_noop('Ready to Collect <span class="count">(%s)</span>', 'Ready to Collect <span class="count">(%s)</span>')
    ));
}

// Add a custom order status to list of WC Order statuses
add_filter('wc_order_statuses', 'add_custom_order_statuses');
function add_custom_order_statuses($order_statuses) {
    $new_order_statuses = array();

    // add new order status before processing
    foreach ($order_statuses as $key => $status) {
        $new_order_statuses[$key] = $status;
        if ('wc-processing' === $key) {
            $new_order_statuses['wc-shipped'] = __('Shipped', 'woocommerce' );
            $new_order_statuses['wc-readytocollect'] = __('Ready to Collect', 'woocommerce' );
        }
    }
    return $new_order_statuses;
}

// Adding custom status statuses to admin order list bulk dropdown
add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 50, 1 );
function custom_dropdown_bulk_actions_shop_order( $actions ) {
    $new_actions = array();

    // add new order status before processing
    foreach ($actions as $key => $action) {
        if ('mark_processing' === $key) {
            $new_actions['mark_shipped'] = __( 'Change status to shipped', 'woocommerce' );
            $new_actions['mark_readytocollect'] = __( 'Change status to Ready to Collect', 'woocommerce' );
        }
        $new_actions[$key] = $action;
    }
    return $new_actions;
}

// Add a custom order statuses action button (for orders with "processing" status)
add_filter( 'woocommerce_admin_order_actions', 'add_custom_order_status_actions_button', 100, 2 );
function add_custom_order_status_actions_button( $actions, $order ) {
    $allowed_statuses = array( 'on-hold', 'processing', 'pending', 'shipped', 'readytocollect' ); // Define allowed statuses

    // Display the button for all orders that have allowed status (as defined in the array)
    if ( in_array( $order->get_status(), $allowed_statuses ) ) {

        // The key slug defined from status with the name
        $action_slugs = array(
            'shipped'        => __('Shipped', 'woocommerce'),
            'readytocollect' => __('Ready to Collect', 'woocommerce')
        );

        // Loop through custom statuses
        foreach ( $action_slugs as $action_slug => $name ) {
            // Display "processing" action button
            $actions['processing'] = array(
                'url'    => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=processing&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
                'name'   => __( 'Processing', 'woocommerce' ),
                'action' => 'processing',
            );

            // Display "complete" action button
            $actions['complete'] = array(
                'url'    => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=completed&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
                'name'   => __( 'Complete', 'woocommerce' ),
                'action' => 'complete',
            );

            // Display custom status action buttons
            if( $order->get_status() !== $action_slug ) {
                // Set the action button
                $actions[$action_slug] = array(
                    'url'       => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status='.$action_slug.'&order_id='.$order->get_id() ), 'woocommerce-mark-order-status' ),
                    'name'      => $name,
                    'action'    => $action_slug,
                );
            }
        }
    }
    return $actions;
}

// Set styling for custom order status action button icon and List icon
add_action( 'admin_head', 'add_custom_order_status_actions_button_css' );
function add_custom_order_status_actions_button_css() {
    // The key slug defined from status with the icon code
    $action_slugs = array(
        'shipped'        => '\e019',
        'readytocollect' => '\e029'
    );
    ?>
    <style>
    <?php foreach ( $action_slugs as $action_slug => $icon_code ) : ?>
        .wc-action-button-<?php echo $action_slug; ?>::after {
            font-family: woocommerce !important; content: "<?php echo $icon_code; ?>" !important;
        }
    <?php endforeach; ?>
    </style>
    <?php
}

// Adding action for custom statuses
add_filter( 'woocommerce_email_actions', 'custom_email_actions', 20, 1 );
function custom_email_actions( $action ) {
    $actions[] = 'woocommerce_order_status_wc-shipped';
    $actions[] = 'woocommerce_order_status_wc-readytocollect';

    return $actions;
}

add_action( 'woocommerce_order_status_wc-shipped', array( 'WC_Emails', 'send_transactional_email' ), 10, 1 );
add_action( 'woocommerce_order_status_wc-readytocollect', array( 'WC_Emails', 'send_transactional_email' ), 10, 1 );


// Sending an email notification when order get a custom status
add_action('woocommerce_order_status_shipped', 'cutom_status_trigger_email_notification', 10, 2 );
add_action('woocommerce_order_status_readytocollect', 'cutom_status_trigger_email_notification', 10, 2 );
function cutom_status_trigger_email_notification( $order_id, $order ) {
    WC()->mailer()->get_emails()['WC_Email_Customer_Processing_Order']->trigger( $order_id );
}

// Customize email heading for your custom statuses email notifications
add_filter( 'woocommerce_email_heading_customer_processing_order', 'custom_email_heading_for_custom_order_status', 10, 2 );
function custom_email_heading_for_custom_order_status( $heading, $order ){
    // Here your custom statuses slugs / Heading texts pairs
    $data = array(
        'shipped'        => __('Planet Vape {order_number} has been Shipped!','woocommerce'),
        'readytocollect' => __('Planet Vape {order_number} is Ready to Collect!','woocommerce')
    );

    // Loop through each custom status / heading text pairs
    foreach ( $data as $custom_status => $heading_text ) {
        // Change an email notification heading text when a order get a custom status
        if( $order->has_status( $custom_status ) ) {
           $email = WC()->mailer()->get_emails()['WC_Email_Customer_Processing_Order']; // Get the specific WC_emails object

           $heading = $email->format_string( $heading_text ); // don't return directly
        }
    }
    return $heading;
}

// Customize email subject for your custom statuses email notifications
add_filter( 'woocommerce_email_subject_customer_processing_order', 'custom_email_subject_for_custom_order_status', 10, 2 );
function custom_email_subject_for_custom_order_status( $subject, $order ){
    // Here your custom statuses slugs / Heading texts pairs
    $data = array(
        'shipped'        => __('Planet Vape {order_number} has been Shipped!','woocommerce'),
        'readytocollect' => __('Planet Vape {order_number} is Ready to Collect!','woocommerce')
    );

    // Loop through each custom status / subject text pairs
    foreach ( $data as $custom_status => $subject_text ) {
        // Change an email notification heading text when a order get a custom status
        if( $order->has_status( $custom_status ) ) {
            $email = WC()->mailer()->get_emails()['WC_Email_Customer_Processing_Order']; // Get the specific WC_emails object

            $subject = $email->format_string( $subject_text ); // don't return directly
        }
    }
    return $subject;
}