While using the EDD API to retrieve downloads I noticed I couldn't use order and orderby parameters to sort the results.
The order and orderby parameters should be allowed to sort downloads as this is already possible with the core REST API.
When using order and orderby, the same results are returned, regardless of the parameters.
Make a request to the products endpoint and try to sort the products using order and orderby:
Example (sorting products by the post name (aka slug) in ascending order: https://yoursite.com/edd-api/products?order=ASC&orderby=name
In the EDD Blocks downloads block (https://github.com/easydigitaldownloads/edd-blocks) there's a select menu for Order and Order By:

I was using the WP REST API to previously sort the downloads but switched to the EDD API. Hoping to get this fixed for 2.9.7 (and also release/3.0 which I'm testing with) if possible 🙏
PR: https://github.com/easydigitaldownloads/easy-digital-downloads/pull/6862
Let me know if there's a better way.
As a reminder @JJJ we'll have to make sure we update this code to use the new query classes in 3.0.
Something I just thought about @amdrew, this gets items from edd_price only, what does this do for variable priced products, since those are stored in a different location and format?
@cklosowski Variable priced downloads still have the edd_price meta_key set, but the meta_value is set to the lowest price option.
I have a test download that is $10.00 – $50.00, and the edd_price meta_key is 10.00. Because of that it still gets ordered correctly whether ASC or DESC but only bases it on the price of 10 (which I think is correct/fair).
:+1: Thanks @amdrew that's what I was curious, kicking up some tests for it now.
Unit tests added.
Most helpful comment
Unit tests added.