Automattic\WooCommerce\Internal\Admin\Orders

ListTable::do_delete()privateWC 1.0

Handles bulk trashing of orders.

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

Хуков нет.

Возвращает

int. Number of orders that were trashed.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->do_delete( $ids, $force_delete ): int;
$ids(int[]) (обязательный)
Order IDs to be trashed.
$force_delete(true|false)
When set, the order will be completed deleted. Otherwise, it will be trashed.
По умолчанию: false

Код ListTable::do_delete() WC 8.6.1

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;
}