GeneratorsWooCommerceCustom Order Status

Custom Order Status Generator

A new order status, wired into the admin dropdown, the orders list filters and the bulk-action menu WooCommerce builds automatically from the registered list.

awaiting-pickup-order-status.php
Saved just now
The status
wc-awaiting-pickup — 18/20 characters
This code is identical whether or not High-Performance Order Storage is on — an order's status is a plain string either way, stored in the wc- prefixed form.
Visibility
Exclude from search
Orders in this status are skipped by the admin search box.
Show in “All” orders list
Counted and listed when no status filter is applied.
Show in the status filter list
Appears as its own filter link above the orders table, with a live count.
Admin badge colour
Give it a colour in the orders list
Adds a small admin_head style block targeting the status badge markup.
<?php
// Generated with WP CodeKit — powered by GrowQuest (https://growquest.io).
/**
 * Plugin Name:       Awaiting pickup order status
 * Description:       Registers the wc-awaiting-pickup order status.
 * Version:           1.0.0
 * Requires PHP:      7.4
 * Requires Plugins:  woocommerce
 * Text Domain:       acme
 */

defined( 'ABSPATH' ) || exit;

/**
 * Register the wc-awaiting-pickup post status.
 */
function acme_register_order_status() {
	register_post_status(
		'wc-awaiting-pickup',
	array(
		'label'                     => _x( 'Awaiting pickup', 'Order status', 'acme' ),
		'public'                    => false,
		'exclude_from_search'       => false,
		'show_in_admin_all_list'    => true,
		'show_in_admin_status_list' => true,
		'label_count'               => _n_noop(
			'Awaiting pickup <span class="count">(%s)</span>',
			'Awaiting pickup <span class="count">(%s)</span>',
			'acme'
		),
	)
	);
}
add_action( 'init', 'acme_register_order_status' );

/**
 * Add it to the list WooCommerce shows everywhere — the admin dropdown,
 * the orders list filters, and the bulk "Change status to" actions.
 *
 * @param array $order_statuses Existing statuses, in display order.
 * @return array
 */
function acme_order_statuses( $order_statuses ) {
	$new_statuses = array();

	foreach ( $order_statuses as $key => $status ) {
		$new_statuses[ $key ] = $status;

		if ( 'wc-processing' === $key ) {
			$new_statuses['wc-awaiting-pickup'] = _x( 'Awaiting pickup', 'Order status', 'acme' );
		}
	}

	return $new_statuses;
}
add_filter( 'wc_order_statuses', 'acme_order_statuses' );

/**
 * Give the status its own colour in the orders list.
 */
function acme_order_status_badge_css() {
	?>
	<style>
		mark.order-status.status-awaiting-pickup,
		.order-status.status-awaiting-pickup {
			background: #f0ad4e;
			color: #ffffff;
		}
	</style>
	<?php
}
add_action( 'admin_head', 'acme_order_status_badge_css' );