Automattic\WooCommerce\Admin

PluginsHelper::get_expired_subscription_notice()public staticWC 1.0

Get formatted notice information for expired subscription.

Method of the class: PluginsHelper{}

No Hooks.

Return

Array. notice information.

Usage

$result = PluginsHelper::get_expired_subscription_notice( $allowed_link );
$allowed_link(true|false)
whether the notice description should include a link.
Default: true

PluginsHelper::get_expired_subscription_notice() code WC 9.3.3

public static function get_expired_subscription_notice( $allowed_link = true ) {
	if ( ! WC_Helper::is_site_connected() ) {
		return array();
	}

	if ( ! self::should_show_notice( self::DISMISS_EXPIRED_SUBS_NOTICE ) ) {
		return array();
	}

	$subscriptions         = WC_Helper::get_subscription_list_data();
	$expired_subscriptions = array_filter(
		$subscriptions,
		function ( $sub ) {
			return ( ! empty( $sub['local']['installed'] ) && ! empty( $sub['product_key'] ) )
					&& ( $sub['active'] || empty( $sub['connections'] ) ) // Active on current site or not connected to any sites.
					&& $sub['expired']
					&& ! $sub['lifetime'];
		},
	);

	if ( ! $expired_subscriptions ) {
		return array();
	}

	$total_expired_subscriptions         = count( $expired_subscriptions );
	self::$can_show_expiring_subs_notice = false;

	$notice_data = self::get_subscriptions_notice_data(
		$subscriptions,
		$expired_subscriptions,
		$total_expired_subscriptions,
		array(
			/* translators: 1) product name 3) URL to My Subscriptions page 4) Renew product price string */
			'single_manage'           => __( 'Your subscription for <strong>%1$s</strong> expired. <a href="%3$s">%4$s</a> to continue receiving updates and streamlined support.', 'woocommerce' ),
			/* translators: 1) product name 3) URL to My Subscriptions page 4) Renew product price string */
			'multiple_manage'         => __( 'One of your subscriptions for <strong>%1$s</strong> has expired. <a href="%3$s">%4$s</a> to continue receiving updates and streamlined support.', 'woocommerce' ),
			/* translators: 1) total expired subscriptions 2) URL to My Subscriptions page */
			'different_subscriptions' => __( 'You have <strong>%1$s Woo extension subscriptions</strong> that expired. <a href="%2$s">Renew</a> to continue receiving updates and streamlined support.', 'woocommerce' ),
		),
		'expired',
	);

	$button_link = add_query_arg(
		array(
			'utm_source'   => 'pu',
			'utm_campaign' => $allowed_link ? 'pu_settings_screen_renew' : 'pu_in_apps_screen_renew',
		),
		self::WOO_SUBSCRIPTION_PAGE_URL
	);

	if ( in_array( $notice_data['type'], array( 'single_manage', 'multiple_manage' ), true ) ) {
		$button_link = add_query_arg(
			array(
				'product_id' => $notice_data['product_id'],
				'type'       => 'expiring',
			),
			$button_link
		);
	}

	return array(
		'description' => $allowed_link ? $notice_data['parsed_message'] : preg_replace( '#<a.*?>(.*?)</a>#i', '\1', $notice_data['parsed_message'] ),
		'button_text' => __( 'Renew', 'woocommerce' ),
		'button_link' => $button_link,
	);
}