WC_REST_Product_Variations_Controller::get_collection_params
Get the query params for collections of attachments.
Method of the class: WC_REST_Product_Variations_Controller{}
No Hooks.
Returns
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() WC REST Product Variations Controller::get collection params code WC 10.5.0
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' ),
),
),
),
);
$params['virtual'] = array(
'description' => __( 'Limit result set to virtual product variations.', 'woocommerce' ),
'type' => 'boolean',
'sanitize_callback' => 'rest_sanitize_boolean',
'validate_callback' => 'rest_validate_request_arg',
);
$params['downloadable'] = array(
'description' => __( 'Limit result set to downloadable product variations.', 'woocommerce' ),
'type' => 'boolean',
'sanitize_callback' => 'rest_sanitize_boolean',
'validate_callback' => 'rest_validate_request_arg',
);
$params['include_status'] = array(
'description' => __( 'Limit result set to product variations with any of the statuses.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'string',
'enum' => array_merge( array( 'any', 'future', 'trash' ), array_keys( get_post_statuses() ) ),
),
'sanitize_callback' => 'wp_parse_list',
'validate_callback' => 'rest_validate_request_arg',
);
$params['exclude_status'] = array(
'description' => __( 'Exclude product variations with any of the statuses from result set.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'string',
'enum' => array_merge( array( 'future', 'trash' ), array_keys( get_post_statuses() ) ),
),
'sanitize_callback' => 'wp_parse_list',
'validate_callback' => 'rest_validate_request_arg',
);
$params['pos_products_only'] = array(
'description' => __( 'Limit result set to variations visible in Point of Sale.', 'woocommerce' ),
'type' => 'boolean',
'sanitize_callback' => 'wc_string_to_bool',
'validate_callback' => 'rest_validate_request_arg',
);
return $params;
}