WC_Admin_List_Table_Orders::handle_bulk_actions()
Handle bulk actions.
Method of the class: WC_Admin_List_Table_Orders{}
Hooks from the method
Return
String
.
Usage
$WC_Admin_List_Table_Orders = new WC_Admin_List_Table_Orders(); $WC_Admin_List_Table_Orders->handle_bulk_actions( $redirect_to, $action, $ids );
- $redirect_to(string) (required)
- URL to redirect to.
- $action(string) (required)
- Action name.
- $ids(array) (required)
- List of ids.
WC_Admin_List_Table_Orders::handle_bulk_actions() WC Admin List Table Orders::handle bulk actions code WC 9.5.1
public function handle_bulk_actions( $redirect_to, $action, $ids ) { $ids = apply_filters( 'woocommerce_bulk_action_ids', array_reverse( array_map( 'absint', $ids ) ), $action, 'order' ); $changed = 0; if ( 'remove_personal_data' === $action ) { $report_action = 'removed_personal_data'; foreach ( $ids as $id ) { $order = wc_get_order( $id ); if ( $order ) { do_action( 'woocommerce_remove_order_personal_data', $order ); $changed++; } } } elseif ( false !== strpos( $action, 'mark_' ) ) { $order_statuses = wc_get_order_statuses(); $new_status = substr( $action, 5 ); // Get the status name from action. $report_action = 'marked_' . $new_status; // Sanity check: bail out if this is actually not a status, or is not a registered status. if ( isset( $order_statuses[ 'wc-' . $new_status ] ) ) { // Initialize payment gateways in case order has hooked status transition actions. WC()->payment_gateways(); foreach ( $ids as $id ) { $order = wc_get_order( $id ); $order->update_status( $new_status, __( 'Order status changed by bulk edit:', 'woocommerce' ), true ); do_action( 'woocommerce_order_edit_status', $id, $new_status ); $changed++; } } } if ( $changed ) { $redirect_to = add_query_arg( array( 'post_type' => $this->list_table_type, 'bulk_action' => $report_action, 'changed' => $changed, 'ids' => join( ',', $ids ), ), $redirect_to ); } return esc_url_raw( $redirect_to ); }