With HPOS enabled, when you view the Subscriptions List Table, the status filters above the table only show WC Order statuses and not subscription statuses:
Issues in this screenshot:
The all(1) count is wrong (should be 3 not 1, isn't counting subscription statuses)
Status filters for Active and Pending Cancellation and all other subscription statuses are missing
To fix these issues, this PR uses the views_woocommerce_page_wc-orders--shop_subscription hook to attach the subscription status filters/views.
Changes in this PR:
New data store function (get_subscriptions_count_by_status()) to fetch subscriptions grouped by status along with the count
New function filter_subscription_list_table_views() which generates an array of [{Subscription Status} (count)]() links used to filter the subscriptions table
How to test this PR
Enable HPOS
Purchase a subscription and make sure the subscription has a non-order status like 'active'.
While on trunk, visit the WooCommerce > Subscriptions table and notice the list of statuses at the top of the table says "All (0)"
Check out this branch and refresh the page. You should see the status filters properly loading above the subscriptions list table.
Purchase more subscriptions and change the statuses to pending-cancelled and or on-hold.
Use the status (count) links to filter the subscriptions table by status.
Product impact
[x] Added changelog entry (or does not apply)
[x] Will this PR affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
[x] Will this PR affect WooCommerce Payments? yes/no/tbc, add issue ref
[ ] Added deprecated functions, hooks or classes to the spreadsheet
Fixes #370
Description
With HPOS enabled, when you view the Subscriptions List Table, the status filters above the table only show WC Order statuses and not subscription statuses:
Issues in this screenshot:
all(1)
count is wrong (should be 3 not 1, isn't counting subscription statuses)Active
andPending Cancellation
and all other subscription statuses are missingTo fix these issues, this PR uses the
views_woocommerce_page_wc-orders--shop_subscription
hook to attach the subscription status filters/views.Changes in this PR:
get_subscriptions_count_by_status()
) to fetch subscriptions grouped by status along with the countfilter_subscription_list_table_views()
which generates an array of [{Subscription Status} (count)
]() links used to filter the subscriptions tableHow to test this PR
trunk
, visit the WooCommerce > Subscriptions table and notice the list of statuses at the top of the table says "All (0)"Product impact