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 25–36 of 36 results
-
Add to cart
Samsung Galaxy S24 Ultra
$1,299.00 -
Sale
Add to cart
Google Pixel 8
Original price was: $699.00.$549.00Current price is: $549.00. -
Add to cart
Google Pixel 8a
$499.00 -
Add to cart
Microsoft Surface Laptop 7 (13.8")
$1,199.00 -
Add to cart
HP Spectre x360 14
$1,449.00 -
Sale
Read more
Acer Swift Go 14
Original price was: $849.00.$699.00Current price is: $699.00. -
Add to cart
iPhone 15
$799.00 -
Add to cart
MacBook Pro 14" (M3 Pro)
$1,999.00 -
Sale
Add to cart
Dell XPS 13 (9340)
Original price was: $1,199.00.$1,049.00Current price is: $1,049.00. -
Add to cart
Lenovo ThinkPad X1 Carbon Gen 12
$1,649.00 -
Sale
Add to cart
ASUS ROG Zephyrus G14 (2024)
Original price was: $1,599.00.$1,399.00Current price is: $1,399.00. -
Sale
Add to cart
MacBook Air 13" (M3)
Original price was: $1,099.00.$999.00Current price is: $999.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.