Hi guys,
do you have a code for me how to edit the woocommerce custom order status?
I want to delete some e.g. on-hold or at shipping.
Thanks and Greetings
Hey mary301187,
Thank you for the inquiry.
You can use the wc_order_statuses filter from the wc_get_order_statuses function (below) to adjust the available statuses but we are not sure how will the changes affect the order process.
/**
* Get all order statuses.
*
* @since 2.2
* @used-by WC_Order::set_status
* @return array
*/
function wc_get_order_statuses() {
$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' ),
);
return apply_filters( 'wc_order_statuses', $order_statuses );
}
Example:
add_filter('wc_order_statuses', function($statuses) {
$statuses['wc-custom-status'] = _x( 'Custom', 'Custom status', 'woocommerce' ),
return $statuses;
}, 10, 1);
Best regards,
Ismael
Hey Ismael,
I paste it info the function.php child theme but nothing happened.
Can you please explain me exactly what to do?
Thank you so much
Hi,
Thank you for the update.
Did you add the filter?
add_filter('wc_order_statuses', function($statuses) {
$statuses['wc-custom-status'] = _x( 'Custom', 'Custom status', 'woocommerce' );
return $statuses;
}, 10, 1);
After adding the filter, try to edit any of the existing orders and set its status to “Custom status”.
Best regards,
Ismael