Skip to content

Instantly share code, notes, and snippets.

@pejantantangguh
Created June 24, 2019 05:41
Show Gist options
  • Save pejantantangguh/6aab7bfcc21cb19d03ee2c483e445e65 to your computer and use it in GitHub Desktop.
Save pejantantangguh/6aab7bfcc21cb19d03ee2c483e445e65 to your computer and use it in GitHub Desktop.
Update Woocoommerce order status in bulk
add_filter ('bulk_actions-edit-shop_order','register_bulk_action');
function register_bulk_action($bulk_actions){
$bulk_actions['mark_being_processed'] = 'Mark Being Processed';
return $bulk_actions;
}
add_action ('admin_action_mark_being_processed','bulk_process_custom_status');
function bulk_process_custom_status() {
if( !isset( $_REQUEST['post'] ) && !is_array( $_REQUEST['post'] ) ) {
return;
} else {
foreach( $_REQUEST['post'] as $order_id ) {
$order = new WC_Order ($order_id);
$order_note = 'Order status changed to Being Processed';
$order->update_status ('being-processed', $order_note, true);
}
$location = add_query_arg (array (
'post_type' => 'shop_order',
'marked_being_processed' => 1,
'changed' => count($_REQUEST['POST'] ),
'ids' => join ($_REQUEST['POST'] , ','),
'post_status' => 'all'
),'edit.php' );
wp_redirect(admin_url($location) );
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment