mirror of
https://github.com/pronamic/woocommerce-subscriptions.git
synced 2025-10-13 21:02:55 +00:00
Updates to 7.9.0
This commit is contained in:
@@ -28,6 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
* 'order_type' Get subscriptions for the any order type in this array. Can include 'any', 'parent', 'renewal', 'resubscribe' or 'switch', defaults to 'parent'.
|
||||
* @return WC_Subscription[] Subscription details in post_id => WC_Subscription form.
|
||||
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
|
||||
* @since 7.9.0 Only instances of WC_Subscriptions will be returned by this function (prior to this, other values including false were occassionally part of the result).
|
||||
*/
|
||||
function wcs_get_subscriptions_for_order( $order, $args = array() ) {
|
||||
|
||||
@@ -72,7 +73,13 @@ function wcs_get_subscriptions_for_order( $order, $args = array() ) {
|
||||
|
||||
foreach ( $subscription_ids as $subscription_id ) {
|
||||
if ( wcs_is_subscription( $subscription_id ) ) {
|
||||
$subscriptions[ $subscription_id ] = wcs_get_subscription( $subscription_id );
|
||||
$subscription = wcs_get_subscription( $subscription_id );
|
||||
|
||||
// This additional check ensures we meet our promise of returning WC_Subscription[], in part by guarding
|
||||
// a against race condition that could lead to $subscription being false.
|
||||
if ( is_a( $subscription, WC_Subscription::class ) ) {
|
||||
$subscriptions[ $subscription_id ] = $subscription;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user