WooCommerce Code Reference

WC_Product_Usage_Notice
in package

Product usage notice class.

Table of Contents

DISMISSED_COUNT_META_PREFIX  = '_woocommerce_product_usage_notice_dismissed_count_'
User meta key prefix to store dismiss counts per product. Product ID is the suffix part.
DISMISSED_TIMESTAMP_META_PREFIX  = '_woocommerce_product_usage_notice_dismissed_timestamp_'
User meta key prefix to store timestamp of last dismissed product usage notice.
LAST_DISMISSED_TIMESTAMP_META  = '_woocommerce_product_usage_notice_last_dismissed_timestamp'
User meta key to store timestamp of last dismissed of any product usage notices. There's no product ID in the meta key.
REMIND_LATER_TIMESTAMP_META_PREFIX  = '_woocommerce_product_usage_notice_remind_later_timestamp_'
User meta key prefix to store timestamp of last clicked remind later from product usage notice. Product ID is the suffix part.
$current_notice_rule  : array<string|int, mixed>
Current product usage notice rule applied to the current admin screen.
$product_usage_notice_rules  : array<string|int, mixed>
Array of product usage notice rules from helper API.
ajax_dismiss()  : mixed
AJAX handler for dismiss action of product usage notice.
ajax_remind_later()  : mixed
AJAX handler for "remind later" action of product usage notice.
enqueue_product_usage_notice_scripts()  : mixed
Enqueue scripts needed to display product usage notice (or modal).
load()  : void
Loads the class, runs on init.
maybe_show_product_usage_notice()  : mixed
Maybe show product usage notice in a given screen object.
get_current_notice_rule()  : array<string|int, mixed>
Get product usage notice rule from a given WP_Screen object.
has_reached_max_dismissals()  : bool
Check whether the user has reached max dismissals of product usage notice.
is_any_notices_dismissed_recently()  : bool
Check whether the user dismissed any product usage notices recently.
is_notice_throttled()  : bool
Check whether current notice is throttled for the user and product.
is_product_notice_dismissed_recently()  : bool
Check whether the user dismissed given product usage notice recently.
is_remind_later_clicked_recently()  : bool
Check whether the user clicked "remind later" recently.
query_string_matches()  : bool
Check whether the screen and GET parameter matches a given rule.

Constants

DISMISSED_COUNT_META_PREFIX

User meta key prefix to store dismiss counts per product. Product ID is the suffix part.

public string DISMISSED_COUNT_META_PREFIX = '_woocommerce_product_usage_notice_dismissed_count_'

DISMISSED_TIMESTAMP_META_PREFIX

User meta key prefix to store timestamp of last dismissed product usage notice.

public string DISMISSED_TIMESTAMP_META_PREFIX = '_woocommerce_product_usage_notice_dismissed_timestamp_'

Product ID is the suffix part.

LAST_DISMISSED_TIMESTAMP_META

User meta key to store timestamp of last dismissed of any product usage notices. There's no product ID in the meta key.

public string LAST_DISMISSED_TIMESTAMP_META = '_woocommerce_product_usage_notice_last_dismissed_timestamp'

REMIND_LATER_TIMESTAMP_META_PREFIX

User meta key prefix to store timestamp of last clicked remind later from product usage notice. Product ID is the suffix part.

public string REMIND_LATER_TIMESTAMP_META_PREFIX = '_woocommerce_product_usage_notice_remind_later_timestamp_'

Properties

Methods

maybe_show_product_usage_notice()

Maybe show product usage notice in a given screen object.

public static maybe_show_product_usage_notice(WP_Screen $screen) : mixed
Parameters
$screen : WP_Screen

Current \WP_Screen object.

Return values
mixed

get_current_notice_rule()

Get product usage notice rule from a given WP_Screen object.

private static get_current_notice_rule(WP_Screen $screen) : array<string|int, mixed>
Parameters
$screen : WP_Screen

Current \WP_Screen object.

Return values
array<string|int, mixed>

has_reached_max_dismissals()

Check whether the user has reached max dismissals of product usage notice.

private static has_reached_max_dismissals(int $user_id, int $product_id) : bool
Parameters
$user_id : int

User ID.

$product_id : int

Product ID.

Return values
bool

is_any_notices_dismissed_recently()

Check whether the user dismissed any product usage notices recently.

private static is_any_notices_dismissed_recently(int $user_id) : bool
Parameters
$user_id : int

User ID.

Return values
bool

is_notice_throttled()

Check whether current notice is throttled for the user and product.

private static is_notice_throttled(int $user_id, int $product_id) : bool
Parameters
$user_id : int

User ID.

$product_id : int

Product ID.

Return values
bool

is_product_notice_dismissed_recently()

Check whether the user dismissed given product usage notice recently.

private static is_product_notice_dismissed_recently(int $user_id, int $product_id) : bool
Parameters
$user_id : int

User ID.

$product_id : int

Product ID.

Return values
bool

is_remind_later_clicked_recently()

Check whether the user clicked "remind later" recently.

private static is_remind_later_clicked_recently(int $user_id, int $product_id) : bool
Parameters
$user_id : int

User ID.

$product_id : int

Product ID.

Return values
bool

query_string_matches()

Check whether the screen and GET parameter matches a given rule.

private static query_string_matches(WP_Screen $screen, array<string|int, mixed> $rule) : bool
Parameters
$screen : WP_Screen

Current \WP_Screen object.

$rule : array<string|int, mixed>

Product usage notice rule.

Return values
bool