mirror of
https://github.com/pronamic/woocommerce-subscriptions.git
synced 2025-10-15 13:52:57 +00:00
2.2.7
This commit is contained in:

committed by
Remco Tolsma

parent
5e536ec717
commit
b99eba2f79
@@ -88,7 +88,7 @@ class WC_REST_Subscriptions_Controller extends WC_REST_Orders_V1_Controller {
|
||||
$date_type_key = ( 'start' === $date_type ) ? 'date_created' : $date_type;
|
||||
$date = $subscription->get_date( $date_type_key );
|
||||
|
||||
$response->data[ $date_type . '_date'] = ( ! empty( $date ) ) ? wc_rest_prepare_date_response( $date ) : '';
|
||||
$response->data[ $date_type . '_date' ] = ( ! empty( $date ) ) ? wc_rest_prepare_date_response( $date ) : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -66,16 +66,22 @@ class WC_API_Subscriptions_Customers extends WC_API_Customers {
|
||||
if ( is_wp_error( $id ) ) {
|
||||
return $id;
|
||||
}
|
||||
$subscription_ids = array();
|
||||
$filter['customer_id'] = $id;
|
||||
$subscriptions = WC()->api->WC_API_Subscriptions->get_subscriptions( $fields, $filter, null, -1 );
|
||||
|
||||
$customer_subscriptions = $subscription_ids = array();
|
||||
$filter['customer_id'] = $id;
|
||||
$subscriptions = WC()->api->WC_API_Subscriptions->get_subscriptions( $fields, $filter, null, -1 );
|
||||
|
||||
if ( ! empty( $subscriptions['subscriptions'] ) && is_array( $subscriptions['subscriptions'] ) ) {
|
||||
foreach ( $subscriptions['subscriptions'] as $subscription ) {
|
||||
$subscription_ids[] = $subscription['id'];
|
||||
if ( isset( $subscription['billing_schedule']['interval'] ) ) { // make sure the interval is not a string to fully support backwards compat.
|
||||
$subscription['billing_schedule']['interval'] = intval( $subscription['billing_schedule']['interval'] );
|
||||
}
|
||||
|
||||
$customer_subscriptions[] = array( 'subscription' => $subscription );
|
||||
$subscription_ids[] = $subscription['id'];
|
||||
}
|
||||
}
|
||||
|
||||
return array( 'customer_subscriptions' => apply_filters( 'wc_subscriptions_api_customer_subscriptions', $subscriptions, $id, $fields, $subscription_ids, $this->server ) );
|
||||
return array( 'customer_subscriptions' => apply_filters( 'wc_subscriptions_api_customer_subscriptions', $customer_subscriptions, $id, $fields, $subscription_ids, $this->server ) );
|
||||
}
|
||||
}
|
||||
|
@@ -694,7 +694,16 @@ class WC_API_Subscriptions extends WC_API_Orders {
|
||||
$query_args['post_status'] = $statuses;
|
||||
|
||||
unset( $args['status'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $args['customer_id'] ) ) {
|
||||
$query_args['meta_query'] = array(
|
||||
array(
|
||||
'key' => '_customer_user',
|
||||
'value' => absint( $args['customer_id'] ),
|
||||
'compare' => '=',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$query_args = $this->merge_query_args( $query_args, $args );
|
||||
|
Reference in New Issue
Block a user