WC_Helper::get_installed_subscriptions()public staticWC 1.0

Get the user's connected subscriptions that are installed on the current site.

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

Хуков нет.

Возвращает

Массив.

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

$result = WC_Helper::get_installed_subscriptions();

Код WC_Helper::get_installed_subscriptions() WC 9.4.2

public static function get_installed_subscriptions() {
	static $installed_subscriptions = null;

	// Cache installed_subscriptions in the current request.
	if ( is_null( $installed_subscriptions ) ) {
		$auth    = WC_Helper_Options::get( 'auth' );
		$site_id = isset( $auth['site_id'] ) ? absint( $auth['site_id'] ) : 0;
		if ( 0 === $site_id ) {
			$installed_subscriptions = array();
			return $installed_subscriptions;
		}

		$installed_subscriptions = array_filter(
			self::get_subscriptions(),
			function ( $subscription ) use ( $site_id ) {
				return in_array( $site_id, $subscription['connections'], true );
			}
		);
	}

	return $installed_subscriptions;
}