Automattic\WooCommerce\Internal\DataStores\Orders

DataSynchronizer::maybe_start_synchronizing_pending_orders()publicWC 1.0

Start an orders synchronization process if all the following is true:

  1. Data synchronization is enabled.
  2. Data synchronization isn't already in progress ($force can be used to bypass this).
  3. There's at least one out of sync order.

This will set up the appropriate status information and schedule the first synchronization batch.

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

Хуков нет.

Возвращает

null. Ничего.

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

$DataSynchronizer = new DataSynchronizer();
$DataSynchronizer->maybe_start_synchronizing_pending_orders( $force );
$force(true|false)
If true, (re)start the sync process even if it's already in progress.
По умолчанию: false

Код DataSynchronizer::maybe_start_synchronizing_pending_orders() WC 6.6.1

public function maybe_start_synchronizing_pending_orders( bool $force = false ) {
	if ( ! $this->data_sync_is_enabled() || ( $this->pending_data_sync_is_in_progress() && ! $force ) ) {
		return;
	}

	$initial_pending_count = $this->get_current_orders_pending_sync_count();
	if ( 0 === $initial_pending_count ) {
		return;
	}

	update_option( self::INITIAL_ORDERS_PENDING_SYNC_COUNT_OPTION, $initial_pending_count );

	$queue = WC()->get_instance_of( \WC_Queue::class );
	$queue->cancel_all( self::ORDERS_SYNC_SCHEDULED_ACTION_CALLBACK );

	update_option( self::PENDING_SYNC_IS_IN_PROGRESS_OPTION, 'yes' );
	$this->schedule_pending_orders_synchronization();
}