Closed mattallan closed 1 year ago
Will WCS_Admin_System_Status::get_subscription_statuses()
be included in this issue?
The sibling method WCS_Admin_System_Status::get_subscriptions_by_gateway()
is also not HPOS-compatible. Should I log a new issue for it?
Will WCS_Admin_System_Status::get_subscription_statuses() be included in this issue?
@Jinksi Yeah i'll update all instances of wp_count_posts()
with this issue.
Thanks for bringing up get_subscriptions_by_gateway()
as well as I haven't come across this one yet. We can handle that in a separate issue I think as it's not related to wp_count_posts()
. I'm not even sure what the right way to fix that would be, maybe just run a different DB query or something when HPOS is enabled. I don't know if going down the route of having a new data store function is necessary since it's not widely used.
We can handle that in a separate issue I think as it's not related to wp_count_posts().
Description
In https://github.com/Automattic/woocommerce-subscriptions-core/pull/372 we introduced a new subscriptions data store function to count subscriptions and group them by their statuses.
This issue is to look at replacing all instances of
wp_count_posts( 'shop_subscription' )
with the newWC_Data_Store::load( 'subscription' )->get_subscriptions_count_by_status();
.Note: There is one instance of
wp_count_posts( 'shop_order' )
used in thewcs_is_large_site()
which won't work on stores with HPOS enabled, but there's no replacement function for this.For now, I'm thinking we only worry about counting orders when the store has HPOS disabled since the idea behind this function is that we throttle the store based on how many orders and subscriptions they have, but performance issues might not be a think on HPOS sites.
So the logic in
wcs_is_large_site()
would change to something like:Product impact
Dev notes
Additional context