WC_REST_WCCOM_Site_Connection_Controller::handle_status_requestpublicWC 9.9.0

Get the status of the WooCommerce.com connection.

Method of the class: WC_REST_WCCOM_Site_Connection_Controller{}

No Hooks.

Returns

WP_Error|WP_REST_Response.

Usage

$WC_REST_WCCOM_Site_Connection_Controller = new WC_REST_WCCOM_Site_Connection_Controller();
$WC_REST_WCCOM_Site_Connection_Controller->handle_status_request();

Changelog

Since 9.9.0 Introduced.

WC_REST_WCCOM_Site_Connection_Controller::handle_status_request() code WC 10.4.3

public function handle_status_request() {
	$auth = WC_Helper_Options::get( 'auth' );
	if ( empty( $auth['access_token'] ) || empty( $auth['access_token_secret'] ) ) {
		return $this->get_response(
			array(
				self::CONNECTION_DATA_FOUND => false,
				self::CONNECTION_VALID      => false,
			)
		);
	}

	$connection_data = WC_Helper::fetch_helper_connection_info();
	if ( $connection_data instanceof WP_Error ) {
		return $connection_data;
	}

	if ( null === $connection_data ) {
		return $this->get_response(
			array(
				self::CONNECTION_DATA_FOUND => true,
				self::CONNECTION_VALID      => false,
			)
		);
	}

	return $this->get_response(
		array_merge(
			array(
				self::CONNECTION_DATA_FOUND => true,
				self::CONNECTION_VALID      => true,
			),
			$connection_data
		)
	);
}