WooCommerce Numeric Custom Field Filter for Battery Life

A WooCommerce numeric custom field filter lets shoppers compare measured product data by a minimum, maximum, or range. This electronics demo uses Battery life in hours; shoppers can set a slider range to compare devices by saved catalog values before choosing one.

Try this: Set a battery-life range to narrow to longer-lasting devices.

How this demo is configured

  • Create a filter by Battery life (hours) (custom field _mfp_battery_hrs). Show as Range slider.
Filters
Battery life (hours)
Battery life (hours)
—

Showing 1–12 of 36 results

How a numeric custom field filter works

The filter reads a custom field as a number and applies the selected range to that value. The demo uses _mfp_battery_hrs; its slider step is one hour. A product must have a value that satisfies the chosen lower or upper bound.

Numeric comparison is different from a text match. A field intended for this filter should store consistent numeric values, not mixed labels such as “long” or “up to ten hours.”

When to filter numeric product data

Use a numeric custom field when a shopper can compare a measurable product property. Battery life, weight, dimensions, and capacity are possible examples when the data is actually saved as numbers.

If the choices are named categories rather than measured values, use a taxonomy filter. If the number is price, use the dedicated product price key and label the range in the store currency.

Set up a battery-life range

  1. Open Filter Sets → Add New and select Products under Content to filter.
  2. Add a filter named Battery life (hours) with a unique URL keyword.
  3. Choose Custom field (number) for What are you filtering? and enter the matching Custom field key.
  4. Under How shoppers choose, select Range / Slider. Set Step size (range only) to match the numeric precision.
  5. Save and test values that correspond to known products in the catalog.

Frequently asked questions

Can this filter use a text field?

It is designed for Custom field (number). Use a text or taxonomy filter for nonnumeric values.

Which battery field does the demo use?

The electronics demo uses the numeric field _mfp_battery_hrs and a one-hour slider step.