Updates to 7.9.0

This commit is contained in:
WooCommerce
2025-09-18 10:16:37 +00:00
parent 7d081fb691
commit 708a1fa4a4
53 changed files with 1174 additions and 401 deletions

View File

@@ -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;
}
}
}