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.
Showing 13–24 of 36 results
-
Sale
Add to cart
JBL Tune 770NC
Original price was: $129.00.$99.00Current price is: $99.00. -
Add to cart
Microsoft Surface Pro 11
$1,199.00 -
Add to cart
Lenovo Tab P12
$349.00 -
Sale
Add to cart
Sony WH-1000XM5
Original price was: $399.00.$329.00Current price is: $329.00. -
Add to cart
Bose QuietComfort Ultra
$429.00 -
Add to cart
OnePlus 12
$799.00 -
Add to cart
Nothing Phone (2a)
$349.00 -
Add to cart
iPad Air 11" (M2)
$599.00 -
Add to cart
iPad Pro 13" (M4)
$1,299.00 -
Sale
Read more
Samsung Galaxy Tab S9
Original price was: $799.00.$649.00Current price is: $649.00. -
Add to cart
iPhone 15 Pro Max
$1,199.00 -
Sale
Read more
Samsung Galaxy S24
Original price was: $799.00.$699.00Current price is: $699.00.
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
- Open Filter Sets → Add New and select Products under Content to filter.
- Add a filter named Battery life (hours) with a unique URL keyword.
- Choose Custom field (number) for What are you filtering? and enter the matching Custom field key.
- Under How shoppers choose, select Range / Slider. Set Step size (range only) to match the numeric precision.
- 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.