In Woocommerce, I'm not able to set an order to one of my custom order statuses: 'wc-order-waiting-to-abort'
. I've created 3 other custom statuses and all of them work fine and can be set to an order.
I've done the exact same thing for those custom status.
The strange thing is that the custom status appears in the dropdown list in WooCommerce, I can select it but when I press Save Order the status isn't saved and stays at the old status. When I select the other custom status and press save the status is successfully saved.
There are no error logs, no warnings, nothing. This is so strange.
Here is my code:
add_action( 'init', 'register_new_order_states_and_status' );
function register_new_order_states_and_status() {
//Bestellung in Bearbeitung
register_post_status( 'wc-order-in-progress', array(
'label' => 'Bestellung in Bearbeitung',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Bestellung in Bearbeitung <span class="count">(%s)</span>', 'Bestellung in Bearbeitung <span class="count">(%s)</span>' )
) );
//Abbruchbestätigung ausstehend
register_post_status( 'wc-order-waiting-to-abort', array(
'label' => 'Abbruchbestätigung ausstehend',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Abbruchbestätigung ausstehend <span class="count">(%s)</span>', 'Abbruchbestätigung ausstehend <span class="count">(%s)</span>' )
) );
//Bestellung abgeschlossen
register_post_status( 'wc-order-finished', array(
'label' => 'Bestellung abgeschlossen',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Bestellung abgeschlossen <span class="count">(%s)</span>', 'Bestellung abgeschlossen <span class="count">(%s)</span>' )
) );
//Bestellung abgenommen
register_post_status( 'wc-order-accepted', array(
'label' => 'Bestellung abgenommen',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Bestellung abgenommen <span class="count">(%s)</span>', 'Bestellung abgenommen <span class="count">(%s)</span>' )
) );
}
/**
* Add new order states to WooCommerce
*/
add_filter( 'wc_order_statuses', 'add_new_order_states' );
function add_new_order_states( $order_states ) {
$new_order_states = array();
foreach ( $order_states as $key => $status ) {
$new_order_states[ $key ] = $status;
if ( $key === 'wc-completed' ) {
$new_order_states['wc-order-in-progress'] = 'Bestellung in Bearbeitung';
$new_order_states['wc-order-waiting-to-abort'] = 'Abbruchbestätigung ausstehend';
$new_order_states['wc-order-finished'] = 'Bestellung abgeschlossen';
$new_order_states['wc-order-accepted'] = 'Bestellung abgenommen';
}
}
return $new_order_states;
}
Any help is appreciated.