Automattic\WooCommerce\Blocks\BlockTypes
MiniCart::handle_render_block_context
Provide a cart product reference to inner blocks rendered in the Mini Cart overlay.
The overlay is rendered out of the regular block tree (via do_blocks() the footer), so this is exposed through the render_block_context rather than a static providesContext declaration.
Method of the class: MiniCart{}
No Hooks.
Returns
array. The block context, with the product reference added while the overlay renders.
Usage
$MiniCart = new MiniCart(); $MiniCart->handle_render_block_context( $context );
- $context(array) (required)
- The block context.
MiniCart::handle_render_block_context() MiniCart::handle render block context code WC 11.3.0
public function handle_render_block_context( $context ) {
if ( ! $this->is_providing_reference_context ) {
return $context;
}
$context['woocommerce/productCollection/referenceType'] = 'cart';
return $context;
}