WC_Helper_Updater::get_subscription_notice
Message for a product's subscription state, or an empty string when there is nothing to say.
Resolves the product's subscriptions once and hands them to whichever message needs them, so a screen full of WooCommerce.com plugins doesn't filter the whole list twice per row.
Method of the class: WC_Helper_Updater{}
No Hooks.
Returns
string.
Usage
$result = WC_Helper_Updater::get_subscription_notice( $product_id, $product_page_url, $campaign_prefix ): string;
- $product_id(int) (required)
- WooCommerce.com product ID.
- $product_page_url(string) (required)
- WooCommerce.com product page URL, or an empty string.
- $campaign_prefix(string) (required)
- Prefix for the link's utm_campaign value.
Changelog
| Since 11.2.0 | Introduced. |
WC_Helper_Updater::get_subscription_notice() WC Helper Updater::get subscription notice code WC 11.2.2
private static function get_subscription_notice( int $product_id, string $product_page_url, string $campaign_prefix ): string {
// While the last subscriptions fetch is still failing, the list is stale or empty, so a
// missing subscription would be a guess rather than a fact.
if ( null !== WC_Helper::get_api_error() ) {
return '';
}
$subscriptions = self::get_subscriptions_for_product( $product_id );
if ( empty( $subscriptions ) ) {
return self::get_purchase_notice( $product_id, $product_page_url, $campaign_prefix );
}
return self::get_renewal_notice( $subscriptions, $campaign_prefix );
}