Send an email notification when custom order status changes in WooCommerce

I have created a custom order status in my WooCommerce called Back Order (wc-backorder):

/**
     * Add custom status to order list
*/
    add_action( 'init', 'register_custom_post_status', 10 );
    function register_custom_post_status() {
        register_post_status( 'wc-backorder', array(
            'label'                     => _x( 'Back Order', 'Order status', 'woocommerce' ),
            'public'                    => true,
            'exclude_from_search'       => false,
            'show_in_admin_all_list'    => true,
            'show_in_admin_status_list' => true,
            'label_count'               => _n_noop( 'Back Order <span class="count">(%s)</span>', 'Back Order <span class="count">(%s)</span>', 'woocommerce' )
        ) );

}

/**
 * Add custom status to order page drop down
 */
add_filter( 'wc_order_statuses', 'custom_wc_order_statuses' );
function custom_wc_order_statuses( $order_statuses ) {
    $order_statuses['wc-backorder'] = _x( 'Back Order', 'Order status', 'woocommerce' );
    return $order_statuses;
}

Now I want to recieve an email whenever an order is recieved that has been given the status quote. I’ve created a plugin based on this helpful article: How to Add a Custom WooCommerce Email

I added hook in function.php:

add_action( 'woocommerce_order_status_wc-order-confirmed', array( WC(), 'send_transactional_email' ), 10, 10 );

function so_27112461_woocommerce_email_actions( $actions ){
    $actions[] = 'woocommerce_order_status_wc-order-confirmed';
    return $actions;
}
add_filter( 'woocommerce_email_actions', 'so_27112461_woocommerce_email_actions' );

Nothing happens when an order changed into the ‘Back Order’ status.

Any ideas?

I’ve tried loads of different hooks but I can’t seem to get the trigger function to run.

Thanks

Read more here: Send an email notification when custom order status changes in WooCommerce

Leave a Reply

Your email address will not be published. Required fields are marked *