WC_Report_Sales_By_Category::get_products_in_category( int $category_id )

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


Description Description


Parameters Parameters

$category_id

(Required) Category ID.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/admin/reports/class-wc-report-sales-by-category.php

	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 ) );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.