Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
87 stars 33 forks source link

Subscription List Table does not sort properly with HPOS #471

Closed jb510 closed 8 months ago

jb510 commented 1 year ago

Describe the bug

Sorting subscriptions by clicking on their column headings does not work correctly. Sometimes it has no effect (starting date) sometimes one gets a random order (next payment date). This is with HPOS enabled, haven't tested recently without but assumed it used to work.

To Reproduce

Enable HPOS Go to the active subscriptions list page /?page=wc-orders--shop_subscription&status=wc-active Sort by "next payment date" notice in the screenshot "in 2 days" shows up in first and fourth position, with "in 6 days" and "July 26th" in between the two.

Click on the "Start Date" heading, and nothing at all seems to happen. It does not sort, nor does it reverse/descending sort after repeated clicks.

Expected behavior

Clicking on column headers should sort correctly when HPOS is enabled.

Actual behavior

Clicking on column headers is either doing nothing, sorting on the wrong column, or sorting completely incorrectly.

Product impact

Impossible to clearly see which subscriptions need attention.

CleanShot 2023-07-14 at 10 57 33@2x

kaushikasomaiya commented 10 months ago

7368486-zen

kaushikasomaiya commented 10 months ago

@james-allan @mattallan Just surfacing this for attention.

james-allan commented 10 months ago

Thanks for the ping @kaushikasomaiya.

This may require some changes to WooCommerce core. I've taken a look at how we can order the list table results however it's rather restrictive.

The WC core function, OrdersTableQuery::process_orderby(), has no entry points where Woo Subscriptions can tell WooCommerce how we want to order the list of results by a custom meta key. @mattallan mentioned that this may have been raised with the core team already but couldn't recall if this is the exact same issue. We'll double check and look into whether this is something that they are already aware of.

james-allan commented 10 months ago

@mattallan mentioned that this may have been raised with the core team already but couldn't recall if this is the exact same issue. We'll double check and look into whether this is something that they are already aware of.

For internal use here's the thread where we discussed in p1672967764366439-slack-C9QDV4TL4. Nothing of noteworthy for public folks, just the report.

WC added support for it here: https://github.com/woocommerce/woocommerce/pull/36403 so we'll need to look into those changes and see if we can integrate with them.

Just noting that this issue is a duplicate of #200.