Automattic\WooCommerce\Internal\Admin\Notes

WooSubscriptionsNotes::get_subscription_active_product_ids()publicWC 1.0

Returns an array of product_ids whose subscriptions are active on this site.

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

Хуков нет.

Возвращает

Массив.

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

$WooSubscriptionsNotes = new WooSubscriptionsNotes();
$WooSubscriptionsNotes->get_subscription_active_product_ids();

Код WooSubscriptionsNotes::get_subscription_active_product_ids() WC 9.3.3

public function get_subscription_active_product_ids() {
	$site_id = $this->get_connected_site_id();
	if ( ! $site_id ) {
		return array();
	}

	$product_ids = array();

	if ( $this->is_connected() ) {
		$subscriptions = \WC_Helper::get_subscriptions();

		foreach ( (array) $subscriptions as $subscription ) {
			if ( in_array( $site_id, $subscription['connections'], true ) ) {
				$product_ids[] = $subscription['product_id'];
			}
		}
	}

	return $product_ids;
}