Automattic\WooCommerce\Blocks\BlockTypes
ProductFilterPrice::register_active_filters_data()
Register the active filters data.
Метод класса: ProductFilterPrice{}
Хуков нет.
Возвращает
Массив
. Active filters data.
Использование
$ProductFilterPrice = new ProductFilterPrice(); $ProductFilterPrice->register_active_filters_data( $data, $params );
- $data(массив) (обязательный)
- The active filters data.
- $params(массив) (обязательный)
- The query param parsed from the URL.
Код ProductFilterPrice::register_active_filters_data() ProductFilterPrice::register active filters data WC 9.4.2
public function register_active_filters_data( $data, $params ) { $min_price = intval( $params[ self::MIN_PRICE_QUERY_VAR ] ?? 0 ); $max_price = intval( $params[ self::MAX_PRICE_QUERY_VAR ] ?? 0 ); $formatted_min_price = $min_price ? wp_strip_all_tags( wc_price( $min_price, array( 'decimals' => 0 ) ) ) : null; $formatted_max_price = $max_price ? wp_strip_all_tags( wc_price( $max_price, array( 'decimals' => 0 ) ) ) : null; if ( ! $formatted_min_price && ! $formatted_max_price ) { return $data; } if ( $formatted_min_price && $formatted_max_price ) { $title = sprintf( /* translators: %1$s and %2$s are the formatted minimum and maximum prices respectively. */ __( 'Between %1$s and %2$s', 'woocommerce' ), $formatted_min_price, $formatted_max_price ); } if ( ! $formatted_min_price ) { /* translators: %s is the formatted maximum price. */ $title = sprintf( __( 'Up to %s', 'woocommerce' ), $formatted_max_price ); } if ( ! $formatted_max_price ) { /* translators: %s is the formatted minimum price. */ $title = sprintf( __( 'From %s', 'woocommerce' ), $formatted_min_price ); } $data['price'] = array( 'type' => __( 'Price', 'woocommerce' ), 'items' => array( array( 'title' => $title, 'attributes' => array( 'data-wc-on--click' => "{$this->get_full_block_name()}::actions.reset", ), ), ), ); return $data; }