WooCommerce Code Reference

SectionInterface extends BlockContainerInterface

Interface for section containers, which contain sub-sections and blocks.

Table of Contents

ATTRIBUTES_KEY  = 'attributes'
Key for the block attributes in the block configuration.
DISABLE_CONDITIONS_KEY  = 'disableConditions'
Key for the block disable conditions in the block configuration.
HIDE_CONDITIONS_KEY  = 'hideConditions'
Key for the block hide conditions in the block configuration.
ID_KEY  = 'id'
Key for the block ID in the block configuration.
NAME_KEY  = 'blockName'
Key for the block name in the block configuration.
ORDER_KEY  = 'order'
Key for the internal order in the block configuration.
add_block()  : BlockInterface
Adds a new block to the section.
add_disable_condition()  : string
Add a disable condition to the block.
add_hide_condition()  : string
Add a hide condition to the block.
add_section()  : SubsectionInterface
Adds a new sub-section to the section.
add_subsection()  : SubsectionInterface
Adds a new sub-section to the section.
get_attributes()  : array<string|int, mixed>
Get the block attributes.
get_block()  : BlockInterface|null
Get a block by ID.
get_disable_conditions()  : array<string|int, mixed>
Get the disable conditions of the block.
get_formatted_template()  : array<string|int, mixed>
Get the block configuration as a formatted template.
get_hide_conditions()  : array<string|int, mixed>
Get the hide conditions of the block.
get_id()  : string
Get the block ID.
get_name()  : string
Get the block name.
get_order()  : int
Get the block order.
get_parent()  : ContainerInterface
Get the parent container that the block belongs to.
get_root_template()  : BlockTemplateInterface
Get the root template that the block belongs to.
is_detached()  : bool
Check if the block is detached from its parent or root template.
remove()  : mixed
Remove the block from its parent.
remove_block()  : mixed
Removes a block from the container.
remove_blocks()  : mixed
Removes all blocks from the container.
remove_disable_condition()  : mixed
Remove a disable condition from the block.
remove_hide_condition()  : mixed
Remove a hide condition from the block.
set_attribute()  : mixed
Set a block attribute value without replacing the entire attributes object.
set_attributes()  : mixed
Set the block attributes.
set_order()  : mixed
Set the block order.

Constants

Methods

add_disable_condition()

Add a disable condition to the block.

public add_disable_condition(string $expression) : string

The disable condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be disabled. See @woocommerce/expression-evaluation for more details.

Parameters
$expression : string

An expression, which if true, will disable the block.

Return values
stringThe key of the disable condition, which can be used to remove the disable condition.

add_hide_condition()

Add a hide condition to the block.

public add_hide_condition(string $expression) : string

The hide condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be hidden. See @woocommerce/expression-evaluation for more details.

Parameters
$expression : string

An expression, which if true, will hide the block.

Return values
stringThe key of the hide condition, which can be used to remove the hide condition.

get_disable_conditions()

Get the disable conditions of the block.

public get_disable_conditions() : array<string|int, mixed>
Return values
array<string|int, mixed>

is_detached()

Check if the block is detached from its parent or root template.

public is_detached() : bool
Return values
boolTrue if the block is detached from its parent or root template.

remove_block()

Removes a block from the container.

public remove_block(string $block_id) : mixed
Parameters
$block_id : string

The block ID.

Tags
throws
UnexpectedValueException

If the block container is not an ancestor of the block.

Return values
mixed

remove_disable_condition()

Remove a disable condition from the block.

public remove_disable_condition(string $key) : mixed
Parameters
$key : string

The key of the disable condition to remove.

Return values
mixed

remove_hide_condition()

Remove a hide condition from the block.

public remove_hide_condition(string $key) : mixed
Parameters
$key : string

The key of the hide condition to remove.

Return values
mixed

set_attribute()

Set a block attribute value without replacing the entire attributes object.

public set_attribute(string $key, mixed $value) : mixed
Parameters
$key : string

The attribute key.

$value : mixed

The attribute value.

Return values
mixed

set_attributes()

Set the block attributes.

public set_attributes(array<string|int, mixed> $attributes) : mixed
Parameters
$attributes : array<string|int, mixed>

The block attributes.

Return values
mixed