WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_REST_Products_V1_Controller::query_args() public WC 1.0

Query args.

Это метод класса: WC_REST_Products_V1_Controller{}

Хуков нет.

Возвращает

Массив.

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

$WC_REST_Products_V1_Controller = new WC_REST_Products_V1_Controller();
$WC_REST_Products_V1_Controller->query_args( $args, $request );
$args(массив) (обязательный)
Request args.
$request(WP_REST_Request) (обязательный)
Request data.

Код WC_REST_Products_V1_Controller::query_args() WC 4.5.2

woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-products-v1-controller.php
<?php
public function query_args( $args, $request ) {
	// Set post_status.
	$args['post_status'] = $request['status'];

	// Taxonomy query to filter products by type, category,
	// tag, shipping class, and attribute.
	$tax_query = array();

	// Map between taxonomy name and arg's key.
	$taxonomies = array(
		'product_cat'            => 'category',
		'product_tag'            => 'tag',
		'product_shipping_class' => 'shipping_class',
	);

	// Set tax_query for each passed arg.
	foreach ( $taxonomies as $taxonomy => $key ) {
		if ( ! empty( $request[ $key ] ) && is_array( $request[ $key ] ) ) {
			$request[ $key ] = array_filter( $request[ $key ] );
		}

		if ( ! empty( $request[ $key ] ) ) {
			$tax_query[] = array(
				'taxonomy' => $taxonomy,
				'field'    => 'term_id',
				'terms'    => $request[ $key ],
			);
		}
	}

	// Filter product type by slug.
	if ( ! empty( $request['type'] ) ) {
		$tax_query[] = array(
			'taxonomy' => 'product_type',
			'field'    => 'slug',
			'terms'    => $request['type'],
		);
	}

	// Filter by attribute and term.
	if ( ! empty( $request['attribute'] ) && ! empty( $request['attribute_term'] ) ) {
		if ( in_array( $request['attribute'], wc_get_attribute_taxonomy_names(), true ) ) {
			$tax_query[] = array(
				'taxonomy' => $request['attribute'],
				'field'    => 'term_id',
				'terms'    => $request['attribute_term'],
			);
		}
	}

	if ( ! empty( $tax_query ) ) {
		$args['tax_query'] = $tax_query;
	}

	// Filter by sku.
	if ( ! empty( $request['sku'] ) ) {
		$skus = explode( ',', $request['sku'] );
		// Include the current string as a SKU too.
		if ( 1 < count( $skus ) ) {
			$skus[] = $request['sku'];
		}

		$args['meta_query'] = $this->add_meta_query( $args, array(
			'key'     => '_sku',
			'value'   => $skus,
			'compare' => 'IN',
		) );
	}

	// Apply all WP_Query filters again.
	if ( is_array( $request['filter'] ) ) {
		$args = array_merge( $args, $request['filter'] );
		unset( $args['filter'] );
	}

	// Force the post_type argument, since it's not a user input variable.
	if ( ! empty( $request['sku'] ) ) {
		$args['post_type'] = array( 'product', 'product_variation' );
	} else {
		$args['post_type'] = $this->post_type;
	}

	return $args;
}