Automattic\WooCommerce\Internal\DataStores\Orders

DataSynchronizer::maybe_prevent_deletion_of_post()publicWC 8.8.0

Prevents deletion of order backup posts (regardless of sync setting) when HPOS is authoritative and the order still exists in HPOS. This should help with edge cases where wp_delete_post() would delete the HPOS record too or backfill would sync incorrect data from an order with no metadata from the posts table.

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

Хуков нет.

Возвращает

WP_Post|false|null.

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

$DataSynchronizer = new DataSynchronizer();
$DataSynchronizer->maybe_prevent_deletion_of_post( $delete, $post );
$delete(WP_Post|false|null) (обязательный)
Whether to go forward with deletion.
$post(WP_Post) (обязательный)
Post object.

Список изменений

С версии 8.8.0 Введена.

Код DataSynchronizer::maybe_prevent_deletion_of_post() WC 9.7.1

public function maybe_prevent_deletion_of_post( $delete, $post ) {
	if ( self::PLACEHOLDER_ORDER_POST_TYPE !== $post->post_type && $this->custom_orders_table_is_authoritative() && $this->data_store->order_exists( $post->ID ) ) {
		$delete = false;
	}

	return $delete;
}