// Maybe filter to a specific user
if ( 0 != $args['customer_id'] && is_numeric( $args['customer_id'] ) ) {
$users_subscription_ids = WCS_Customer_Store::instance()->get_users_subscription_ids( $args['customer_id'] );
$query_args = WCS_Admin_Post_Types::set_post__in_query_var( $query_args, $users_subscription_ids );
};
For large stores without HPOS this can be a significant hit to performance when querying for subscriptions by customer_id so it should still be used when HPOS is disabled.
Acceptance criteria
For stores with HPOS disabled, bring back the above approach of using the user's subscription cache data + post__in query args when querying by customer ID
For stores with HPOS enabled, continue to query using customer_id and remove the need for the users subscription cache.
Describe the bug
In https://github.com/Automattic/woocommerce-subscriptions-core/pull/171 we removed this block of code inside our
wcs_get_subscriptions()
function as it was no longer necessary with HPOS enabled:For large stores without HPOS this can be a significant hit to performance when querying for subscriptions by
customer_id
so it should still be used when HPOS is disabled.Acceptance criteria
post__in
query args when querying by customer IDcustomer_id
and remove the need for the users subscription cache.