How Price Range Filters Work

Centralized price range definitions for easy management and user-friendly filters

Price RangeFilterSSOTUX
2 min read

Price Range Filter Challenges

EC site price range filters seem simple but have several challenges:

  • Management difficulty: Defining price ranges separately in filter UI and API processing causes inconsistencies
  • Change impact: Modifying price ranges requires changes in multiple places
  • Backward compatibility: Saved URLs stop working if URL format changes

Solution: Centralized Management (SSOT)

We adopted the SSOT (Single Source of Truth) approach. Price range definitions are consolidated in one file, and all processing references that file.

Example Price Range Definitions

Price ranges are set based on customer purchasing behavior:

range_1
Range$0-$200
Display LabelUp to $200
range_2
Range$201-$400
Display Label$201-$400
range_3
Range$401-$600
Display Label$401-$600
range_4
Range$601-$800
Display Label$601-$800
range_5
Range$801+
Display Label$800+

Benefits of Centralized Management

1. Easy Changes

When you want to modify price ranges, just update one definition file. Filter UI, API processing, URL parameter parsing—everything automatically uses the new definitions.

2. No Inconsistencies

With definitions in only one place, issues like "selectable in UI but errors in API" don't occur.

3. Backward Compatibility

The system that auto-converts old URL formats (e.g., 0-200) to new formats (e.g., range_1) also references the definition file.

Processing Flow

Price Range Filter Processing
Customer selects price range
Clicks "Up to $200"
Reflected in URL parameter
?priceRange=range_1
Reference definition file
range_1 → min: 0, max: 200
Send price condition to Shopify API
price: { min: 0, max: 200 }
Return matching products only
Filter complete
Handling Old URL Format
Old URL
?priceRange=0-200
Conversion
Reference definition file
Processed as new format
?priceRange=range_1

Utility Functions

Price range processing is standardized so it can be used the same way everywhere:

  • Get range from ID: range_1{ min: 0, max: 200 }
  • Convert old format: 0-200range_1
  • Check if price is in range: $150 is in range_1

Summary

By centrally managing price range definitions, we achieved filter functionality that's easy to change and resistant to inconsistencies. Maintaining backward compatibility ensures saved URLs continue to work.

Related Topics