BlocksSharedState
Manages the registration of interactivity config and state that is commonly shared by WooCommerce blocks.
Initialization only happens on the first call to initialize_shared_config. Intended to be used as a singleton.
Table of Contents
- $blocks_shared_cart_state : mixed
- Cart state.
- $consent_statement : string
- The consent statement for using private APIs of this class.
- $core_config_registered : bool
- Whether the core config has been registered.
- $settings_namespace : string
- The namespace for the config.
- initialize_shared_config() : mixed
- Initialize the shared core config.
- register_cart_interactivity() : void
- Initialize interactivity state for cart that is needed by multiple blocks.
- check_consent() : true
- Check that the consent statement was passed.
- get_core_data() : array<string|int, mixed>
- Get core data to include in settings.
- get_currency_data() : array<string|int, mixed>
- Get currency data to include in settings.
- get_locale_data() : array<string|int, mixed>
- Get locale data to include in settings.
- prevent_cache() : mixed
- Prevent caching on certain pages
Properties
$blocks_shared_cart_state
Cart state.
private
static mixed
$blocks_shared_cart_state
$consent_statement
The consent statement for using private APIs of this class.
private
static string
$consent_statement
= 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WooCommerce'
$core_config_registered
Whether the core config has been registered.
private
static bool
$core_config_registered
= false
$settings_namespace
The namespace for the config.
private
static string
$settings_namespace
= 'woocommerce'
Methods
initialize_shared_config()
Initialize the shared core config.
public
initialize_shared_config(string $consent_statement) : mixed
Parameters
- $consent_statement : string
-
- The consent statement string.
Return values
mixed —register_cart_interactivity()
Initialize interactivity state for cart that is needed by multiple blocks.
public
register_cart_interactivity(string $consent_statement) : void
Parameters
- $consent_statement : string
-
- The consent statement string.
Return values
void —check_consent()
Check that the consent statement was passed.
private
static check_consent(string $consent_statement) : true
Parameters
- $consent_statement : string
-
- The consent statement string.
Tags
Return values
true —get_core_data()
Get core data to include in settings.
private
static get_core_data() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_currency_data()
Get currency data to include in settings.
private
static get_currency_data() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_locale_data()
Get locale data to include in settings.
private
static get_locale_data() : array<string|int, mixed>
Return values
array<string|int, mixed> —prevent_cache()
Prevent caching on certain pages
private
static prevent_cache() : mixed