WC_REST_Report_Products_Totals_Controller::get_reports()protectedWC 3.5.0

Get reports list.

Метод класса: WC_REST_Report_Products_Totals_Controller{}

Хуков нет.

Возвращает

Массив.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_reports();

Список изменений

С версии 3.5.0 Введена.

Код WC_REST_Report_Products_Totals_Controller::get_reports() WC 8.7.0

protected function get_reports() {
	$types = wc_get_product_types();
	$terms = get_terms(
		array(
			'taxonomy'   => 'product_type',
			'hide_empty' => false,
		)
	);
	$data  = array();

	foreach ( $terms as $product_type ) {
		if ( ! isset( $types[ $product_type->name ] ) ) {
			continue;
		}

		$data[] = array(
			'slug'  => $product_type->name,
			'name'  => $types[ $product_type->name ],
			'total' => (int) $product_type->count,
		);
	}

	return $data;
}