Automattic\WooCommerce\Blocks\BlockTypes
ProductFilterAttribute::render_attribute_dropdown()
Method of the class: ProductFilterAttribute{}
No Hooks.
Return
null
. Nothing (null).
Usage
$ProductFilterAttribute = new ProductFilterAttribute(); $ProductFilterAttribute->/**;
ProductFilterAttribute::render_attribute_dropdown() ProductFilterAttribute::render attribute dropdown code WC 9.7.1
/** * Retrieve the attribute count for current block. * * @param WP_Block $block Block instance. * @param string $slug Attribute slug. * @param string $query_type Query type, accept 'and' or 'or'. */ private function get_attribute_counts( $block, $slug, $query_type ) { $filters = Package::container()->get( QueryFilters::class ); $query_vars = ProductCollectionUtils::get_query_vars( $block, 1 ); if ( 'and' !== strtolower( $query_type ) ) { unset( $query_vars[ 'filter_' . str_replace( 'pa_', '', $slug ) ] ); } if ( isset( $query_vars['taxonomy'] ) && false !== strpos( $query_vars['taxonomy'], 'pa_' ) ) { unset( $query_vars['taxonomy'], $query_vars['term'] ); } if ( ! empty( $query_vars['tax_query'] ) ) { // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query $query_vars['tax_query'] = ProductCollectionUtils::remove_query_array( $query_vars['tax_query'], 'taxonomy', $slug ); } $counts = $filters->get_attribute_counts( $query_vars, $slug ); $attribute_counts = array(); foreach ( $counts as $key => $value ) { $attribute_counts[] = array( 'term' => $key, 'count' => $value,