I would like to get all slugs and names of all the WooCommerce order statuses. I tried the answers from the following thread: Woocommerce get list of order statuses list but with no success.
I use latest woocommerce version. Any help is appreciated.
You will use the dedicated function wc_get_order_statuses()
, from WC_Order functions, which give you by default the following array:
$order_statuses = array(
'wc-pending' => _x( 'Pending payment', 'Order status', 'woocommerce' ),
'wc-processing' => _x( 'Processing', 'Order status', 'woocommerce' ),
'wc-on-hold' => _x( 'On hold', 'Order status', 'woocommerce' ),
'wc-completed' => _x( 'Completed', 'Order status', 'woocommerce' ),
'wc-cancelled' => _x( 'Cancelled', 'Order status', 'woocommerce' ),
'wc-refunded' => _x( 'Refunded', 'Order status', 'woocommerce' ),
'wc-failed' => _x( 'Failed', 'Order status', 'woocommerce' ),
);
All custom additional order statuses will be included too as the filter hook
wc_order_statuses
is applied inside this function.