Easy-digital-downloads: EDD API doesn't support "order" and "orderby" parameters for products endpoint

Created on 19 Aug 2018  ·  6Comments  ·  Source: easydigitaldownloads/easy-digital-downloads

While using the EDD API to retrieve downloads I noticed I couldn't use order and orderby parameters to sort the results.

Bug Report

Expected behavior

The order and orderby parameters should be allowed to sort downloads as this is already possible with the core REST API.

Actual behavior

When using order and orderby, the same results are returned, regardless of the parameters.

Steps to reproduce the behavior

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

Use case

In the EDD Blocks downloads block (https://github.com/easydigitaldownloads/edd-blocks) there's a select menu for Order and Order By:

screen shot 2018-08-19 at 5 36 56 pm

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 🙏

type-feature

Most helpful comment

Unit tests added.

All 6 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mihaijoldis picture mihaijoldis  ·  5Comments

davidsherlock picture davidsherlock  ·  4Comments

JJJ picture JJJ  ·  5Comments

DevinWalker picture DevinWalker  ·  6Comments

mindctrl picture mindctrl  ·  4Comments