WC_Helper::wccom_activate()protected staticWC 1.0

Activate the product subscription to WCCOM

Method of the class: WC_Helper{}

No Hooks.

Return

Array.

Usage

$result = WC_Helper::wccom_activate( $product_key ): array;
$product_key(string) (required)
the product key to be activated.

WC_Helper::wccom_activate() code WC 9.7.1

protected static function wccom_activate( $product_key ): array {
	$activation_response = WC_Helper_API::post(
		'activate',
		array(
			'authenticated' => true,
			'body'          => wp_json_encode(
				array(
					'product_key' => $product_key,
				)
			),
		)
	);

	$activated = wp_remote_retrieve_response_code( $activation_response ) === 200;
	$body      = json_decode( wp_remote_retrieve_body( $activation_response ), true );

	if ( ! $activated && ! empty( $body['code'] ) && 'already_connected' === $body['code'] ) {
		$activated = true;
	}

	return array( $activation_response, $activated, $body );
}