Automattic\WooCommerce\Blocks\BlockTypes

ProductFilterPrice::get_filtered_price()privateWC 1.0

Retrieve the price filter data for current block.

Method of the class: ProductFilterPrice{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->get_filtered_price( $block );
$block(WP_Block) (required)
Block instance.

ProductFilterPrice::get_filtered_price() code WC 9.0.1

private function get_filtered_price( $block ) {
	$filters    = Package::container()->get( QueryFilters::class );
	$query_vars = ProductCollectionUtils::get_query_vars( $block, 1 );

	unset( $query_vars['min_price'], $query_vars['max_price'] );

	if ( ! empty( $query_vars['meta_query'] ) ) {
		// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
		$query_vars['meta_query'] = ProductCollectionUtils::remove_query_array( $query_vars['meta_query'], 'key', '_price' );
	}

	$price_results = $filters->get_filtered_price( $query_vars );

	return array(
		'min_price' => intval( floor( $price_results->min_price ?? 0 ) ),
		'max_price' => intval( ceil( $price_results->max_price ?? 0 ) ),
	);
}