WC_API_Products::query_products()privateWC 2.1

Helper method to get product post objects

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

Хуков нет.

Возвращает

WP_Query.

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

// private - только в коде основоного (родительского) класса
$result = $this->query_products( $args );
$args(массив) (обязательный)
request arguments for filtering query

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

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

Код WC_API_Products::query_products() WC 7.5.1

private function query_products( $args ) {

	// set base query arguments
	$query_args = array(
		'fields'      => 'ids',
		'post_type'   => 'product',
		'post_status' => 'publish',
		'meta_query'  => array(),
	);

	if ( ! empty( $args['type'] ) ) {

		$types = explode( ',', $args['type'] );

		$query_args['tax_query'] = array(
			array(
				'taxonomy' => 'product_type',
				'field'    => 'slug',
				'terms'    => $types,
			),
		);

		unset( $args['type'] );
	}

	$query_args = $this->merge_query_args( $query_args, $args );

	return new WP_Query( $query_args );
}