Automattic\WooCommerce\Blocks\BlockTypes
SingleProduct::update_context()
Update the context by injecting the correct post data for each one of the Single Product inner blocks.
Метод класса: SingleProduct{}
Хуков нет.
Возвращает
Массив
. Updated block context.
Использование
$SingleProduct = new SingleProduct(); $SingleProduct->update_context( $context, $block, $parent_block );
- $context(массив) (обязательный)
- Block context.
- $block(массив) (обязательный)
- Block attributes.
- $parent_block(WP_Block) (обязательный)
- Block instance.
Код SingleProduct::update_context() SingleProduct::update context WC 9.4.2
public function update_context( $context, $block, $parent_block ) { if ( 'woocommerce/single-product' === $block['blockName'] && isset( $block['attrs']['productId'] ) ) { $this->product_id = $block['attrs']['productId']; $this->single_product_inner_blocks_names = array_reverse( $this->extract_single_product_inner_block_names( $block ) ); } $this->replace_post_for_single_product_inner_block( $block, $context ); return $context; }