WC_Helper_Updater::get_renewal_notice
Message for a plugin whose subscription has expired or is lapsing.
Returns an empty string for a subscription that needs no action.
Method of the class: WC_Helper_Updater{}
No Hooks.
Returns
string.
Usage
$result = WC_Helper_Updater::get_renewal_notice( $subscriptions, $campaign_prefix ): string;
- $subscriptions(array) (required)
- Every subscription the account holds for the product.
- $campaign_prefix(string) (required)
- Prefix for the link's utm_campaign value.
Changelog
| Since 11.2.0 | Introduced. |
WC_Helper_Updater::get_renewal_notice() WC Helper Updater::get renewal notice code WC 11.2.2
private static function get_renewal_notice( array $subscriptions, string $campaign_prefix ): string {
list( $expired_subscription, $expiring_subscription ) = self::get_renewable_subscriptions( $subscriptions );
if ( ! empty( $expired_subscription ) ) {
return sprintf(
/* translators: 1: URL of the WooCommerce.com cart set up to renew the subscription */
__( 'Your subscription for this extension has expired. <a href="%1$s" class="woocommerce-renew-subscription">Renew your subscription</a> for security updates, product improvements, and support.', 'woocommerce' ),
esc_url( self::get_renew_link( $expired_subscription, $campaign_prefix . '_renew' ) )
);
}
if ( ! empty( $expiring_subscription ) ) {
$autorenew_link = add_query_arg(
array(
'utm_source' => 'pu',
'utm_campaign' => $campaign_prefix . '_enable_autorenew',
),
PluginsHelper::WOO_SUBSCRIPTION_PAGE_URL
);
// Auto-renew still needs turning on when the record carries no usable expiry; only
// the date is unknown, so name everything except the day.
if ( ! is_numeric( $expiring_subscription['expires'] ?? null ) ) {
return sprintf(
/* translators: 1: URL of the My Subscriptions page */
__( 'Your subscription for this extension expires soon. <a href="%1$s" class="woocommerce-enable-autorenew">Enable auto-renew</a> to keep getting updates and support.', 'woocommerce' ),
esc_url( $autorenew_link )
);
}
return sprintf(
/* translators: 1: Expiry date, 2: URL of the My Subscriptions page */
__( 'Your subscription for this extension expires on %1$s. <a href="%2$s" class="woocommerce-enable-autorenew">Enable auto-renew</a> to keep getting updates and support.', 'woocommerce' ),
wp_date( get_option( 'date_format' ), (int) $expiring_subscription['expires'] ),
esc_url( $autorenew_link )
);
}
return '';
}