Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::persist_save()protectedWC 1.0

Helper method responsible for persisting new data to order table.

This should not contain and specific meta or actions, so that it can be used other order types safely.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->persist_save( $order, $force_all_fields, $backfill );
$order(\WC_Order) (обязательный) (передается по ссылке — &)
Order object.
$force_all_fields(true|false)
Force update all fields, instead of calculating and updating only changed fields.
По умолчанию: false
$backfill(true|false)
Whether to backfill data to post datastore.
По умолчанию: true

Код OrdersTableDataStore::persist_save() WC 8.5.2

protected function persist_save( &$order, bool $force_all_fields = false, $backfill = true ) {
	$order->set_version( Constants::get_constant( 'WC_VERSION' ) );
	$order->set_currency( $order->get_currency() ? $order->get_currency() : get_woocommerce_currency() );

	if ( ! $order->get_date_created( 'edit' ) ) {
		$order->set_date_created( time() );
	}

	if ( ! $order->get_date_modified( 'edit' ) ) {
		$order->set_date_modified( current_time( 'mysql' ) );
	}

	$this->persist_order_to_db( $order, $force_all_fields );

	$this->update_order_meta( $order );

	$order->save_meta_data();
	$order->apply_changes();

	if ( $backfill ) {
		self::$backfilling_order_ids[] = $order->get_id();
		$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() ) );
	}
	$this->clear_caches( $order );
}