WC_REST_Product_Variations_Controller::get_collection_params()publicWC 1.0

Get the query params for collections of attachments.

Method of the class: WC_REST_Product_Variations_Controller{}

No Hooks.

Return

Array.

Usage

$WC_REST_Product_Variations_Controller = new WC_REST_Product_Variations_Controller();
$WC_REST_Product_Variations_Controller->get_collection_params();

WC_REST_Product_Variations_Controller::get_collection_params() code WC 8.6.1

public function get_collection_params() {
	$params = parent::get_collection_params();

	unset(
		$params['in_stock'],
		$params['type'],
		$params['featured'],
		$params['category'],
		$params['tag'],
		$params['shipping_class'],
		$params['attribute'],
		$params['attribute_term']
	);

	$params['stock_status'] = array(
		'description'       => __( 'Limit result set to products with specified stock status.', 'woocommerce' ),
		'type'              => 'string',
		'enum'              => array_keys( wc_get_product_stock_status_options() ),
		'sanitize_callback' => 'sanitize_text_field',
		'validate_callback' => 'rest_validate_request_arg',
	);

	$params['has_price'] = array(
		'description'       => __( 'Limit result set to products with or without price.', 'woocommerce' ),
		'type'              => 'boolean',
		'sanitize_callback' => 'wc_string_to_bool',
		'validate_callback' => 'rest_validate_request_arg',
	);

	$params['attributes'] = array(
		'description' => __( 'Limit result set to products with specified attributes.', 'woocommerce' ),
		'type'        => 'array',
		'items'       => array(
			'type'       => 'object',
			'properties' => array(
				'attribute' => array(
					'type'        => 'string',
					'description' => __( 'Attribute slug.', 'woocommerce' ),
				),
				'term'      => array(
					'type'        => 'string',
					'description' => __( 'Attribute term.', 'woocommerce' ),
				),
				'terms'     => array(
					'type'        => 'array',
					'description' => __( 'Attribute terms.', 'woocommerce' ),
				),
			),
		),
	);

	return $params;
}