Closed
Description
Describe the bug
Being able to order products by orderby
parameter for rand
was missing.
Prerequisites
- I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- The issue still exists against the latest
trunk
branch of CoCart on GitHub. - The issue still exists against the latest
development
branch of CoCart on GitHub (this is not the same version as on WordPress.org!). - I have attempted to find the simplest possible steps to reproduce the issue.
Steps to reproduce the issue
- Make a request
wp-json/cocart/v2/products?orderby=rand
- Response returns a 400 error - see response below.
{
"code": "rest_invalid_param",
"message": "Invalid parameter(s): orderby",
"data": {
"status": 400,
"params": {
"orderby": "orderby is not one of date, id, menu_order, include, title, slug, name, popularity, alphabetical, reverse_alpha, by_stock, review_count, on_sale_first, featured_first, price_asc, price_desc, sales, and rating."
},
"details": {
"orderby": {
"code": "rest_not_in_enum",
"message": "orderby is not one of date, id, menu_order, include, title, slug, name, popularity, alphabetical, reverse_alpha, by_stock, review_count, on_sale_first, featured_first, price_asc, price_desc, sales, and rating.",
"data": null
}
}
}
}
Expected/actual behavior
I was expecting to see products returned at random.
Isolating the problem
- This bug happens with only WooCommerce and CoCart plugin are active.
- This bug happens with a default WordPress theme active.
- This bug happens with the WordPress theme Storefront active.
- This bug happens with the latest release of WooCommerce active.
- This bug happens only when I authenticate as a customer.
- This bug happens only when I authenticate as administrator.
- I can reproduce this bug consistently using the steps above.