Automattic\WooCommerce\Blocks\BlockTypes

ProductQuery::enqueue_data()protectedWC 1.0

Extra data passed through from server to client for block.

Method of the class: ProductQuery{}

Hooks from the method

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->enqueue_data( $attributes );
$attributes(array)
Any attributes that currently are available from the block. Note, this will be empty in the editor context when the block is not in the post content on editor load.
Default: []

ProductQuery::enqueue_data() code WC 9.4.2

protected function enqueue_data( array $attributes = [] ) {
	parent::enqueue_data( $attributes );

	$post_template_has_support_for_grid_view = $this->check_if_post_template_has_support_for_grid_view();

	$this->asset_data_registry->add(
		'postTemplateHasSupportForGridView',
		$post_template_has_support_for_grid_view
	);

	// The `loop_shop_per_page` filter can be found in WC_Query::product_query().
	// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
	$this->asset_data_registry->add( 'loopShopPerPage', apply_filters( 'loop_shop_per_page', wc_get_default_products_per_row() * wc_get_default_product_rows_per_page() ) );
}