Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::persist_updates()protectedWC 1.0

Helper method that is responsible for persisting order updates to the database.

This is expected to be reused by other order types, and should not contain any specific metadata updates or actions.

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

Хуков нет.

Возвращает

Массив. $changes Array of changes.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->persist_updates( $order, $backfill );
$order(\WC_Order) (обязательный) (передается по ссылке — &)
Order object.
$backfill(true|false)
Whether to backfill data to post tables.
По умолчанию: true

Код OrdersTableDataStore::persist_updates() WC 8.7.0

protected function persist_updates( &$order, $backfill = true ) {
	// Fetch changes.
	$changes = $order->get_changes();

	if ( ! isset( $changes['date_modified'] ) ) {
		$order->set_date_modified( current_time( 'mysql' ) );
	}

	$this->persist_order_to_db( $order );

	$this->update_order_meta( $order );

	$order->save_meta_data();

	if ( $backfill ) {
		self::$backfilling_order_ids[] = $order->get_id();
		$this->clear_caches( $order );
		$r_order = wc_get_order( $order->get_id() ); // Refresh order to account for DB changes from post hooks.
		$this->maybe_backfill_post_record( $r_order );
		self::$backfilling_order_ids = array_diff( self::$backfilling_order_ids, array( $order->get_id() ) );
	}

	return $changes;
}