mirror of
https://github.com/pronamic/woocommerce-subscriptions.git
synced 2025-10-17 23:02:56 +00:00
2.3.2
This commit is contained in:

committed by
Remco Tolsma

parent
5fb62b0e6a
commit
1039aec2d9
@@ -174,16 +174,21 @@ function wcs_get_users_subscriptions( $user_id = 0 ) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
|
||||
$subscriptions = apply_filters( 'wcs_pre_get_users_subscriptions', array(), $user_id );
|
||||
$subscriptions = array();
|
||||
|
||||
if ( has_filter( 'wcs_pre_get_users_subscriptions' ) ) {
|
||||
wcs_deprecated_function( 'The "wcs_pre_get_users_subscriptions" hook should no longer be used. A persistent caching layer is now in place. Because of this, "wcs_pre_get_users_subscriptions"', '2.3.0' );
|
||||
$subscriptions = apply_filters( 'wcs_pre_get_users_subscriptions', $subscriptions, $user_id );
|
||||
}
|
||||
|
||||
if ( empty( $subscriptions ) && 0 !== $user_id && ! empty( $user_id ) ) {
|
||||
$post_ids = wcs_get_cached_user_subscription_ids( $user_id );
|
||||
$subscription_ids = WCS_Customer_Store::instance()->get_users_subscription_ids( $user_id );
|
||||
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
$subscription = wcs_get_subscription( $post_id );
|
||||
foreach ( $subscription_ids as $subscription_id ) {
|
||||
$subscription = wcs_get_subscription( $subscription_id );
|
||||
|
||||
if ( $subscription ) {
|
||||
$subscriptions[ $post_id ] = $subscription;
|
||||
$subscriptions[ $subscription_id ] = $subscription;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,24 +206,8 @@ function wcs_get_users_subscriptions( $user_id = 0 ) {
|
||||
* @return array Array of Subscription IDs.
|
||||
*/
|
||||
function wcs_get_users_subscription_ids( $user_id ) {
|
||||
$query = new WP_Query();
|
||||
|
||||
return $query->query( array(
|
||||
'post_type' => 'shop_subscription',
|
||||
'posts_per_page' => -1,
|
||||
'post_status' => 'any',
|
||||
'orderby' => 'date',
|
||||
'order' => 'desc',
|
||||
'fields' => 'ids',
|
||||
'no_found_rows' => true,
|
||||
'ignore_sticky_posts' => true,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_customer_user',
|
||||
'value' => $user_id,
|
||||
),
|
||||
),
|
||||
) );
|
||||
wcs_deprecated_function( __FUNCTION__, '2.3.0', 'WCS_Customer_Store::instance()->get_users_subscription_ids()' );
|
||||
return WCS_Customer_Store::instance()->get_users_subscription_ids( $user_id );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,23 +220,15 @@ function wcs_get_users_subscription_ids( $user_id ) {
|
||||
* @return array Array of subscription IDs.
|
||||
*/
|
||||
function wcs_get_cached_user_subscription_ids( $user_id = 0 ) {
|
||||
wcs_deprecated_function( __FUNCTION__, '2.3.0', 'WCS_Customer_Store::instance()->get_users_subscription_ids()' );
|
||||
|
||||
$user_id = absint( $user_id );
|
||||
|
||||
if ( 0 === $user_id ) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
|
||||
// If the user ID is still zero, bail early.
|
||||
if ( 0 === $user_id ) {
|
||||
return apply_filters( 'wcs_get_cached_users_subscription_ids', array(), $user_id );
|
||||
}
|
||||
|
||||
$subscription_ids = WC_Subscriptions::$cache->cache_and_get(
|
||||
"wcs_user_subscriptions_{$user_id}",
|
||||
'wcs_get_users_subscription_ids',
|
||||
array( $user_id )
|
||||
);
|
||||
|
||||
return apply_filters( 'wcs_get_cached_users_subscription_ids', $subscription_ids, $user_id );
|
||||
return WCS_Customer_Store::instance()->get_users_subscription_ids( $user_id );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,6 +303,11 @@ function wcs_can_user_put_subscription_on_hold( $subscription, $user = '' ) {
|
||||
* Retrieve available actions that a user can perform on the subscription
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
* @param WC_Subscription $subscription The subscription.
|
||||
* @param int $user_id The user.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wcs_get_all_user_actions_for_subscription( $subscription, $user_id ) {
|
||||
|
||||
|
Reference in New Issue
Block a user