WordPress at Your Fingertips
function is not described

WC_Admin_Addons::get_extension_data() public WC 1.0

Call API to get extensions

{} It's a method of the class: WC_Admin_Addons{}

No Hooks.

Return

Object. of extensions and promotions.

Usage

$result = WC_Admin_Addons::get_extension_data( $category, $term, $country );
$category(string) (required)
Addon (sub) category.
$term(string) (required)
Search terms.
$country(string) (required)
Store country.

Code of WC_Admin_Addons::get_extension_data() WC 5.9.0

public static function get_extension_data( $category, $term, $country ) {
	$parameters = self::build_parameter_string( $category, $term, $country );

	$headers = array();
	$auth    = WC_Helper_Options::get( 'auth' );

	if ( ! empty( $auth['access_token'] ) ) {
		$headers['Authorization'] = 'Bearer ' . $auth['access_token'];
	}

	$raw_extensions = wp_safe_remote_get(
		'https://woocommerce.com/wp-json/wccom-extensions/1.0/search' . $parameters,
		array( 'headers' => $headers )
	);

	if ( ! is_wp_error( $raw_extensions ) ) {
		$addons = json_decode( wp_remote_retrieve_body( $raw_extensions ) );
	}
	return $addons;
}