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

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->persist_save( $order, $force_all_fields, $backfill );
$order(\WC_Order) (required) (passed by reference — &)
Order object.
$force_all_fields(true|false)
-
Default: false
$backfill **
-
Default: true

Code of OrdersTableDataStore::persist_save() WC 7.1.0

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

	$this->update_order_meta( $order );

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

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

	if ( $backfill ) {
		$this->maybe_backfill_post_record( $order );
	}
	$this->clear_caches( $order );
}