add_action('init', 'aovup_register_awaiting_dispatch_order_status'); function aovup_register_awaiting_dispatch_order_status() { register_post_status('wc-awaiting-dispatch', array( 'label' => 'Awaiting Dispatch', 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Awaiting Dispatch <span class="count">(%s)</span>', 'Awaiting Dispatch <span class="count">(%s)</span>') )); } add_filter('wc_order_statuses', 'aovup_add_awaiting_dispatch_to_order_statuses'); function aovup_add_awaiting_dispatch_to_order_statuses($order_statuses) { $order_statuses['wc-awaiting-dispatch'] = 'Awaiting Dispatch'; return $order_statuses; } add_filter('bulk_actions-edit-shop_order', 'aovup_add_awaiting_dispatch_bulk_action'); function aovup_add_awaiting_dispatch_bulk_action($bulk_actions) { // Add a new bulk action named "Mark Awaiting Dispatch" $bulk_actions['mark_awaiting-dispatch'] = 'Mark Awaiting Dispatch'; return $bulk_actions; } add_filter('handle_bulk_actions-edit-shop_order', 'aovup_handle_mark_awaiting_dispatch_bulk_action', 10, 3); function aovup_handle_mark_awaiting_dispatch_bulk_action($redirect_to, $doaction, $post_ids) { if ($doaction !== 'mark_awaiting-dispatch') { return $redirect_to; } foreach ($post_ids as $post_id) { $order = wc_get_order($post_id); $order->update_status('awaiting-dispatch'); } $redirect_to = add_query_arg('bulk_awaiting_dispatch_orders', count($post_ids), $redirect_to); return $redirect_to; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter