Automattic\WooCommerce\Internal\Admin\Orders

ListTable::do_delete()privateWC 1.0

Handles bulk trashing of orders.

Method of the class: ListTable{}

No Hooks.

Return

Int. Number of orders that were trashed.

Usage

// private - for code of main (parent) class only
$result = $this->do_delete( $ids, $force_delete ): int;
$ids(int[]) (required)
Order IDs to be trashed.
$force_delete(true|false)
When set, the order will be completed deleted. Otherwise, it will be trashed.
Default: false

ListTable::do_delete() code WC 8.9.0

private function do_delete( array $ids, bool $force_delete = false ): int {
	$changed = 0;

	foreach ( $ids as $id ) {
		$order = wc_get_order( $id );
		$order->delete( $force_delete );
		$updated_order = wc_get_order( $id );

		if ( ( $force_delete && false === $updated_order ) || ( ! $force_delete && $updated_order->get_status() === 'trash' ) ) {
			++$changed;
		}
	}

	return $changed;
}