Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
85 stars 31 forks source link

[HPOS] Allow admins to filter the Subscriptions List Table when HPOS is enabled. #360

Closed mattallan closed 1 year ago

mattallan commented 1 year ago

Fixes #334

Description

The Subscriptions List Table allows store managers to filter subscriptions by product, customer and payment method, however, these filters weren't working when HPOS is enabled:

image

On non-HPOS stores, we are hooking onto the request filter and modifying the WP Query to return results based on the filters set in GET params. However this request filter isn't used on the new WC Orders List Table page.

On stores that have HPOS enabled, WooCommerce has provided a new hook that lets us filter the table results by modifying the params sent to wc_get_orders().

This PR fixes being able to filter the Subscriptions List Table by implementing the following changes:

How to test this PR

  1. Purchase multiple different subscription products to help with testing the filtering by product
  2. Manually create/add a subscription via the Admin page with a manual payment method
  3. Go to WooCommerce > Subscriptions
  4. With HPOS enabled:
  5. Filter the subscriptions table by product
  6. Filter the subscriptions table by customer (also check for customers that have no subscriptions)
  7. Filter the subscriptions table by payment method (check "none", "woocommerce payments" and "manual payments")
  8. Run through the same tests with HPOS disabled.

Product impact

james-allan commented 1 year ago

These changes look good to me and work well.

I've tested filtering the subscription list table on HPOS and CPT environments using various combinations of payment method, customer and product. All searches returned appropriate results.