WC_Report_Sales_By_Category::get_products_in_category()publicWC 1.0

Get all product ids in a category (and its children).

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

Возвращает

Массив.

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

$WC_Report_Sales_By_Category = new WC_Report_Sales_By_Category();
$WC_Report_Sales_By_Category->get_products_in_category( $category_id );
$category_id(int) (обязательный)
Category ID.

Код WC_Report_Sales_By_Category::get_products_in_category() WC 9.4.2

public function get_products_in_category( $category_id ) {
	$term_ids    = get_term_children( $category_id, 'product_cat' );
	$term_ids[]  = $category_id;
	$product_ids = get_objects_in_term( $term_ids, 'product_cat' );

	return array_unique( apply_filters( 'woocommerce_report_sales_by_category_get_products_in_category', $product_ids, $category_id ) );
}