WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

Automattic\WooCommerce\Admin\Features

Onboarding::append_product_data() public WC 1.0

Append dynamic product data from API.

{} Это метод класса: Onboarding{}

Хуков нет.

Возвращает

Массив.

Использование

$result = Onboarding::append_product_data( $product_types );
$product_types(массив) (обязательный)
Array of product types.

Код Onboarding::append_product_data() WC 4.7.1

<?php
public static function append_product_data( $product_types ) {
	$woocommerce_products = get_transient( self::PRODUCT_DATA_TRANSIENT );
	if ( false === $woocommerce_products ) {
		$woocommerce_products = wp_remote_get( 'https://woocommerce.com/wp-json/wccom-extensions/1.0/search' );
		if ( is_wp_error( $woocommerce_products ) ) {
			return $product_types;
		}

		set_transient( self::PRODUCT_DATA_TRANSIENT, $woocommerce_products, DAY_IN_SECONDS );
	}

	$product_data = json_decode( $woocommerce_products['body'] );
	$products     = array();

	// Map product data by ID.
	if ( isset( $product_data ) && isset( $product_data->products ) ) {
		foreach ( $product_data->products as $product_datum ) {
			if ( isset( $product_datum->id ) ) {
				$products[ $product_datum->id ] = $product_datum;
			}
		}
	}

	// Loop over product types and append data.
	foreach ( $product_types as $key => $product_type ) {
		if ( isset( $product_type['product'] ) && isset( $products[ $product_type['product'] ] ) ) {
			$price        = html_entity_decode( $products[ $product_type['product'] ]->price );
			$yearly_price = (float) str_replace( '$', '', $price );

			$product_types[ $key ]['yearly_price'] = $yearly_price;
			$product_types[ $key ]['description']  = $products[ $product_type['product'] ]->excerpt;
			$product_types[ $key ]['more_url']     = $products[ $product_type['product'] ]->link;
			$product_types[ $key ]['slug']         = strtolower( preg_replace( '~[^\pL\d]+~u', '-', $products[ $product_type['product'] ]->slug ) );
		} elseif ( isset( $product_type['product'] ) ) {
			/* translators: site currency symbol (used to show that the product costs money) */
			$product_types[ $key ]['label'] .= sprintf( __( ' — %s', 'woocommerce' ), html_entity_decode( get_woocommerce_currency_symbol() ) );
		}
	}

	return $product_types;
}