Add Bulk actions to Woocommerce products list
<?php
/**
* PHP 5.3 and WP 4.7 is required
*/
//apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
// Add our actions to list
add_filter( "bulk_actions-edit-shop_order", function($actions) {
$statuses = wc_get_order_statuses();
foreach ($statuses as $key => $name) {
$actions[ 'set-' . $key] = "Set status \"" . $name . "\"";
}
return $actions;
}, 9 );
// Process Action
add_action( "admin_init", function() {
// Make sure that we on "Woocomerce orders list" page
if ( !isset($_GET['post_type']) || $_GET['post_type'] != 'shop_order' ) {
return;
}
if ( isset($_GET['action']) && 'set-' === substr( $_GET['action'], 0, 4 ) ) {
// Check Nonce
if ( !check_admin_referer("bulk-posts") ) {
return;
}
// Remove 'set-' from action
$new_status = substr( $_GET['action'], 4 );
$posts = $_GET['post'];
foreach ($posts as $postID) {
if ( !is_numeric($postID) ) {
continue;
}
$order = new WC_Order( (int)$postID );
$order->update_status( $new_status, 'Bulk actions' );
}
}
}, 0 );