Automattic\WooCommerce\Internal\Admin\Orders

ListTable::handle_bulk_actions()publicWC 1.0

Handle bulk actions.

Метод класса: ListTable{}

Hooks from the method

Return

null. Nothing.

Usage

$ListTable = new ListTable();
$ListTable->handle_bulk_actions();

Code of ListTable::handle_bulk_actions() WC 7.1.0

public function handle_bulk_actions() {
	$action = $this->current_action();

	if ( ! $action ) {
		return;
	}

	check_admin_referer( 'bulk-orders' );

	$redirect_to = remove_query_arg( array( 'deleted', 'ids' ), wp_get_referer() );
	$redirect_to = add_query_arg( 'paged', $this->get_pagenum(), $redirect_to );

	/**
	 * Allows 3rd parties to modify order IDs about to be affected by a bulk action.
	 *
	 * @param array Array of order IDs.
	 */
	$ids = apply_filters( // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingSinceComment
		'woocommerce_bulk_action_ids',
		isset( $_REQUEST['order'] ) ? array_reverse( array_map( 'absint', $_REQUEST['order'] ) ) : array(),
		$action,
		'order'
	);

	if ( ! $ids ) {
		wp_safe_redirect( $redirect_to );
		exit;
	}

	$report_action = '';
	$changed       = 0;

	if ( 'remove_personal_data' === $action ) {
		$report_action = 'removed_personal_data';
		$changed       = $this->do_bulk_action_remove_personal_data( $ids );
	} elseif ( 'trash' === $action ) {
		$changed       = $this->do_delete( $ids );
		$report_action = 'trashed';
	} elseif ( 'delete' === $action ) {
		$changed       = $this->do_delete( $ids, true );
		$report_action = 'deleted';
	} elseif ( 'untrash' === $action ) {
		$changed       = $this->do_untrash( $ids );
		$report_action = 'untrashed';
	} elseif ( false !== strpos( $action, 'mark_' ) ) {
		$order_statuses = wc_get_order_statuses();
		$new_status     = substr( $action, 5 );
		$report_action  = 'marked_' . $new_status;

		if ( isset( $order_statuses[ 'wc-' . $new_status ] ) ) {
			$changed = $this->do_bulk_action_mark_orders( $ids, $new_status );
		}
	}

	if ( $changed ) {
		$redirect_to = add_query_arg(
			array(
				'bulk_action' => $report_action,
				'changed'     => $changed,
				'ids'         => implode( ',', $ids ),
			),
			$redirect_to
		);
	}

	wp_safe_redirect( $redirect_to );
	exit;
}