WC_Report_Sales_By_Category::get_products_in_category
Get all product ids in a category (and its children).
Method of the class: WC_Report_Sales_By_Category{}
Hooks from the method
Returns
Array.
Usage
$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) (required)
- Category ID.
WC_Report_Sales_By_Category::get_products_in_category() WC Report Sales By Category::get products in category code WC 10.3.6
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 ) );
}