Automattic\WooCommerce\Admin\API

AnalyticsImports::get_statuspublicWC 1.0

Get the current import status.

Method of the class: AnalyticsImports{}

No Hooks.

Returns

\WP_REST_Response|WP_Error. Response object on success, or WP_Error object on failure.

Usage

$AnalyticsImports = new AnalyticsImports();
$AnalyticsImports->get_status( $request );
$request(required)
.

AnalyticsImports::get_status() code WC 10.7.0

public function get_status( $request ) {
	$is_scheduled_mode = $this->is_scheduled_import_enabled();
	$mode              = $is_scheduled_mode ? 'scheduled' : 'immediate';

	$response = array(
		'mode'                      => $mode,
		'last_processed_date'       => null,
		'next_scheduled'            => null,
		'import_in_progress_or_due' => null,
	);

	// For scheduled mode, populate additional fields.
	if ( $is_scheduled_mode ) {
		$last_processed_gmt                    = get_option( OrdersScheduler::LAST_PROCESSED_ORDER_DATE_OPTION, null );
		$response['last_processed_date']       = ( is_string( $last_processed_gmt ) && $last_processed_gmt ) ? get_date_from_gmt( $last_processed_gmt, 'Y-m-d H:i:s' ) : null;
		$response['next_scheduled']            = $this->get_next_scheduled_time();
		$response['import_in_progress_or_due'] = $this->is_import_in_progress_or_due();
	}

	return rest_ensure_response( $response );
}