Automattic\WooCommerce\DataBase\Migrations\CustomOrderTable

CLIRunner::count_unmigrated()publicWC 1.0

Count how many orders have yet to be migrated into the custom orders table.

EXAMPLES

wp wc cot count_unmigrated

Method of the class: CLIRunner{}

No Hooks.

Return

Int. The number of orders to be migrated.*

Usage

$CLIRunner = new CLIRunner();
$CLIRunner->count_unmigrated( $args, $assoc_args ) : int;
$args(array)
Positional arguments passed to the command.
Default: array()
$assoc_args(array)
Associative arguments (options) passed to the command.
Default: array()

CLIRunner::count_unmigrated() code WC 7.1.1

public function count_unmigrated( $args = array(), $assoc_args = array() ) : int {
	if ( ! $this->is_enabled() ) {
		return 0;
	}

	// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
	$order_count = $this->synchronizer->get_current_orders_pending_sync_count();

	$assoc_args = wp_parse_args(
		$assoc_args,
		array(
			'log' => true,
		)
	);
	if ( isset( $assoc_args['log'] ) && $assoc_args['log'] ) {
		WP_CLI::log(
			sprintf(
				/* Translators: %1$d is the number of orders to be synced. */
				_n(
					'There is %1$d order to be synced.',
					'There are %1$d orders to be synced.',
					$order_count,
					'woocommerce'
				),
				$order_count
			)
		);
	}

	return (int) $order_count;
}