WooCommerce Code Reference

BlocksSharedState
in package

Manages the registration of interactivity config and state that is commonly shared by WooCommerce blocks.

Initialization only happens on the first call to load_store_config.

This is a private API and may change in future versions.

Table of Contents

$blocks_shared_cart_state  : array<string|int, mixed>|null
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.
load_cart_state()  : void
Load cart state into interactivity state.
load_placeholder_image()  : void
Load placeholder image into interactivity config.
load_store_config()  : void
Load store config (currency, locale, core data) into interactivity config.
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()  : void
Prevent caching on certain pages.

Properties

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'

Methods

load_cart_state()

Load cart state into interactivity state.

public static load_cart_state(string $consent_statement) : void
Parameters
$consent_statement : string

The consent statement string.

Tags
throws
InvalidArgumentException

If consent statement doesn't match.

Return values
void

load_placeholder_image()

Load placeholder image into interactivity config.

public static load_placeholder_image(string $consent_statement) : void
Parameters
$consent_statement : string

The consent statement string.

Tags
throws
InvalidArgumentException

If consent statement doesn't match.

Return values
void

load_store_config()

Load store config (currency, locale, core data) into interactivity config.

public static load_store_config(string $consent_statement) : void
Parameters
$consent_statement : string

The consent statement string.

Tags
throws
InvalidArgumentException

If consent statement doesn't match.

Return values
void

Check that the consent statement was passed.

private static check_consent(string $consent_statement) : true
Parameters
$consent_statement : string

The consent statement string.

Tags
throws
InvalidArgumentException

If the statement does not match.

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>