WC_Helper::get_available_subscription()protected staticWC 1.0

Get subscriptions for a product if it is available

Метод класса: WC_Helper{}

Хуков нет.

Возвращает

Разное|null.

Использование

$result = WC_Helper::get_available_subscription( $product_id );
$product_id(строка|int) (обязательный)
the product id to get subscriptions for.

Код WC_Helper::get_available_subscription() WC 9.7.1

protected static function get_available_subscription( $product_id ) {
	$subscriptions = self::_get_subscriptions_from_product_id( $product_id, false );

	// No valid subscriptions for this product.
	if ( empty( $subscriptions ) ) {
		return null;
	}

	$subscription = null;
	foreach ( $subscriptions as $_sub ) {

		// Don't attempt to activate expired subscriptions.
		if ( $_sub['expired'] ) {
			continue;
		}

		// No more sites available in this subscription.
		if ( isset( $_sub['maxed'] ) && $_sub['maxed'] ) {
			continue;
		}

		// Looks good.
		$subscription = $_sub;
		break;
	}

	return $subscription;
}