In WooCommerce, it is possible to add custom order statuses to the default statuses such as “Completed,” “Processing,” and “Pending.” Here is an example of how you can add a custom status called “On Hold” to WooCommerce:

  1. First, you need to add the custom status to the order statuses using the woocommerce_register_shop_order_statuses filter:
add_filter( 'woocommerce_register_shop_order_statuses', 'register_custom_order_status' );
function register_custom_order_status( $order_statuses ) {
    $order_statuses['wc-on-hold'] = _x( 'On Hold', 'Order status', 'textdomain' );
    return $order_statuses;
}
  1. Next, you need to add the custom status to the order actions dropdown, so it can be applied to an order:
add_filter( 'wc_order_statuses', 'custom_order_status' );
function custom_order_status( $order_statuses ) {
    $order_statuses['wc-on-hold'] = _x( 'On Hold', 'Order status', 'textdomain' );
    return $order_statuses;
}
  1. You may want to add custom statuses in bulk, in that case you can use a foreach loop to add multiple custom statuses:
$custom_statuses = array("status1", "status2", "status3");

foreach ($custom_statuses as $status) {
    add_filter( 'woocommerce_register_shop_order_statuses', 'register_custom_order_status' );
    function register_custom_order_status( $order_statuses ) {
        $order_statuses['wc-'.$status] = _x( ucfirst($status), 'Order status', 'textdomain' );
        return $order_statuses;
    }

    add_filter( 'wc_order_statuses', 'custom_order_status' );
    function custom_order_status( $order_statuses ) {
        $order_statuses['wc-'.$status] = _x( ucfirst($status), 'Order status', 'textdomain' );
        return $order_statuses;
    }
}

Note: You should add this code to your theme’s functions.php file or in a custom plugin so that it will work on your website. Also it is important to ensure that the custom statuses have unique keys, and should not use the keys that are already used by WooCommerce.

(Visited 41 times, 1 visits today)
Was this article helpful?
YesNo
Close Search Window