I am using WooCommerce JSON API on my mobile app but I am having problems sorting the the product list.
This is my url https://www.storeurl.com/wp-json/wc/v1/products
but I don't know which parameters to add to the url to sort the products according to price
, reviews
, rating
and popularity
.
I have read the docs but I couldn't find it. Please do you know I could do this?
You just need to append the parameters as part of the query string like so...
https://www.storeurl.com/wc-api/v3/products?orderby=title&order=asc
To take that further, you can use the "Filter" parameter, which allows you to use any WP_Query style arguments you may want to add to your request. So for example, if you wish to sort by "Price", you would do something like...
https://www.storeurl.com/wc-api/v3/products?filter[order]=asc&filter[orderby]=meta_value_num&filter[orderby_meta_key]=_regular_price
Filter - Use WP Query arguments to modify the response; private query vars require appropriate authorization.
Ref: https://woothemes.github.io/woocommerce-rest-api-docs/#list-all-products
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With