Automattic\WooCommerce\Admin
PluginsHelper::get_expired_subscription_notice
Get formatted notice information for expired subscription.
Method of the class: PluginsHelper{}
No Hooks.
Returns
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() PluginsHelper::get expired subscription notice code WC 10.8.1
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::$subscription_usage_notices_already_shown = true;
$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) product name 3) URL to My Subscriptions page */
'multiple_manage_site_covered' => __( 'One of your subscriptions for <strong>%1$s</strong> has expired. This store is still covered by another active subscription.', '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_text = __( 'Renew', 'woocommerce' );
$button_link = add_query_arg(
array(
'add-to-cart' => $notice_data['product_id'],
'utm_source' => 'pu',
'utm_campaign' => $allowed_link ? 'pu_settings_screen_renew' : 'pu_in_apps_screen_renew',
),
self::WOO_CART_PAGE_URL
);
if ( 'multiple_manage_site_covered' === $notice_data['type'] ) {
$button_text = __( 'Review subscriptions', 'woocommerce' );
$button_link = add_query_arg(
array(
'product_id' => $notice_data['product_id'],
'type' => 'expired',
'utm_source' => 'pu',
'utm_campaign' => $allowed_link ? 'pu_settings_screen_review_subscriptions' : 'pu_in_apps_screen_review_subscriptions',
),
self::WOO_SUBSCRIPTION_PAGE_URL
);
} elseif ( in_array( $notice_data['type'], array( 'single_manage', 'multiple_manage' ), true ) ) {
$button_link = add_query_arg(
array(
'add-to-cart' => $notice_data['product_id'],
),
$button_link
);
}
return array(
'description' => $allowed_link ? $notice_data['parsed_message'] : preg_replace( '#<a.*?>(.*?)</a>#i', '\1', $notice_data['parsed_message'] ),
'button_text' => $button_text,
'button_link' => $button_link,
);
}