protected function prepare_items_query($prepared_args = array(), $request = null)
{
$valid_vars = array_flip($this->get_allowed_query_vars());
$query_args = array();
foreach ($valid_vars as $var => $index) {
if (isset($prepared_args[$var])) {
/**
* Filter the query_vars used in `get_items` for the constructed query.
*
* The dynamic portion of the hook name, $var, refers to the query_var key.
*
* @param mixed $prepared_args[ $var ] The query_var value.
*
*/
$query_args[$var] = apply_filters("woocommerce_rest_query_var-{$var}", $prepared_args[$var]);
}
}
$query_args['ignore_sticky_posts'] = true;
if ('include' === $query_args['orderby']) {
$query_args['orderby'] = 'post__in';
} elseif ('id' === $query_args['orderby']) {
$query_args['orderby'] = 'ID';
// ID must be capitalized
}
return $query_args;
}