WC_Product_Grouped::get_primed_visible_childrenprivateWC 1.0

Get visible child products with post caches primed to avoid extra queries.

Method of the class: WC_Product_Grouped{}

No Hooks.

Returns

WC_Product[]. Visible child products.

Usage

// private - for code of main (parent) class only
$result = $this->get_primed_visible_children( $context );
$context(string)
What the value is for. Valid values are view and edit.
Default: 'view'

WC_Product_Grouped::get_primed_visible_children() code WC 10.8.1

private function get_primed_visible_children( $context = 'view' ) {
	$child_ids = $this->get_children( $context );
	if ( ! empty( $child_ids ) ) {
		// Prime caches to reduce future queries.
		_prime_post_caches( $child_ids );
	}
	$children = array_filter( array_map( 'wc_get_product', $child_ids ), 'wc_products_array_filter_visible_grouped' );
	/** @var WC_Product[] $children */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
	return $children;
}