# `PhoenixKitEcommerce.Web.Components.FilterHelpers`
[🔗](https://github.com/BeamLabEU/phoenix_kit_ecommerce/blob/v0.1.8/lib/phoenix_kit_ecommerce/web/components/filter_helpers.ex#L1)

Shared helpers for storefront filter state management.

Used by both ShopCatalog and CatalogCategory LiveViews to:
- Load enabled filters and aggregate values
- Parse filter params from URL query string
- Build query opts for product listing
- Build URLs with filter params

# `active_filter_count`

Counts the number of active filter values (for mobile badge).

# `build_filter_url`

Builds a URL path with filter query params.

Merges filter state into a clean query string, preserving page param only
when `keep_page` is true.

# `build_query_opts`

Converts active filter state into keyword opts for `Shop.list_products_with_count/1`.

# `build_query_string`

Builds a query string from active filter state (e.g. `"?price_min=10&price_max=100"` or `""`).

Used to append filter params to navigation links so filter state persists
across page transitions.

# `has_active_filters?`

Returns true if any filters are currently active.

# `load_filter_data`

Loads enabled filters and their aggregated values.

Returns `{filters, filter_values}` tuple.

Options:
- `:category_uuid` - Scope aggregation to a category by UUID

# `parse_filter_params`

Parses URL query params into active filter state.

Returns a map: `%{"price" => %{min: Decimal, max: Decimal}, "vendor" => ["V1", "V2"], ...}`

# `toggle_filter_value`

Toggles a value in a checkbox-type filter.
Returns updated active_filters map.

# `update_price_filter`

Updates price range filter.
Returns updated active_filters map.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
