WC_Admin_List_Table_Orders::handle_bulk_actions() public WC 1.0
Handle bulk actions.
{} Это метод класса: WC_Admin_List_Table_Orders{}
Хуки из метода
Возвращает
Строку.
Использование
$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(строка) (обязательный)
- URL to redirect to.
- $action(строка) (обязательный)
- Action name.
- $ids(массив) (обязательный)
- List of ids.
Код WC_Admin_List_Table_Orders::handle_bulk_actions() WC Admin List Table Orders::handle bulk actions WC 5.0.0
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 );
}