Add an "Awaiting Shipment" Order Status
Registers a new order status you can set on orders that are packed and waiting for the carrier, and adds it to the bulk actions menu.
Opens WPIDE on
Code
add_filter( 'woocommerce_register_shop_order_post_statuses', function ( $statuses ) {
$statuses['wc-awaiting-shipment'] = array(
'label' => 'Awaiting shipment',
'public' => false,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
/* translators: %s: number of orders */
'label_count' => _n_noop( 'Awaiting shipment <span class="count">(%s)</span>', 'Awaiting shipment <span class="count">(%s)</span>' ),
);
return $statuses;
} );
add_filter( 'wc_order_statuses', function ( $statuses ) {
$new = array();
foreach ( $statuses as $key => $label ) {
$new[ $key ] = $label;
if ( 'wc-processing' === $key ) {
$new['wc-awaiting-shipment'] = 'Awaiting shipment';
}
}
return $new;
} );
$wpide_awaiting_bulk = function ( $actions ) {
$actions['mark_awaiting-shipment'] = 'Change status to awaiting shipment';
return $actions;
};
add_filter( 'bulk_actions-woocommerce_page_wc-orders', $wpide_awaiting_bulk, 20 );
add_filter( 'bulk_actions-edit-shop_order', $wpide_awaiting_bulk, 20 );
add_filter( 'woocommerce_reports_order_statuses', function ( $statuses ) {
if ( is_array( $statuses ) ) {
$statuses[] = 'awaiting-shipment';
}
return $statuses;
} );
Notes
Change the slug and label to create a different status. Orders keep this status if you later remove the snippet, so move them to another status first.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.