Case study: Fixing variable product price range display in WooCommerce + Algolia

TL;DR:
A WooCommerce site’s product category pages were only showing the minimum price of variable products instead of the full price range. Freshy’s development team diagnosed the issue as a sync misconfiguration between WooCommerce and Algolia, which was failing to index min/max price data. The team implemented a solution to pull accurate price ranges from WooCommerce, sync them correctly to Algolia, and resolve related sale price display issues.

Case Study: Fixing Variable Product Price Range Sync in WooCommerce + Algolia

Issue Background

The client reported that their product category pages were not displaying variable product price ranges (e.g., “$9.99 – $49.99”) as expected. Instead, only the minimum price was being shown, creating confusion for customers browsing products with multiple price options.

The site used a heavily customized WooCommerce setup, paired with Algolia search integration, which added complexity to the price display logic.

Diagnosis

Upon investigation, the Freshy team discovered:

  • The theme’s category page templates were pulling product data from Algolia, not directly from WooCommerce.
  • The min_price and max_price values were missing from Algolia’s indexed product data.
  • Product pages themselves were using WooCommerce queries and did have access to accurate min/max pricing using:
$product->get_variation_regular_price( 'max' );
$product->get_variation_regular_price( 'min' );

Additionally, the team found that:

  • Scheduled sale prices were not syncing properly with Algolia.
  • Products with .0 in the price (e.g., $108.50) were being trimmed to one decimal place ($108.5).
  • Edge cases with old data showed incorrect prices (e.g., showing $0.00).

Resolution Steps

The team took the following steps to resolve the issue:

1. Algolia Index Updates

  • Added min_price and max_price attributes to Algolia’s indexing configuration.
  • Implemented a batch update process using wp_update_post() and manual bulk edits to force WooCommerce to sync all product data to Algolia.
  • Developed a JavaScript snippet to enable bulk selection on the WooCommerce product admin screen:
document.querySelectorAll('#the-list input[type="checkbox"]').forEach(input => input.checked = true);

2. Frontend Price Display Fixes

  • Updated the category and product page templates to:
    • Show a full price range when min and max prices differ.
    • Properly strike through regular prices when a sale price is active.
    • Prevent price ranges from showing when there’s only a single price.
    • Format prices correctly with two decimal places.

3. Sale Price Sync Enhancement

  • Identified that scheduled sale prices were not triggering Algolia syncs.
  • Recommended including sale_start_date and sale_end_date in Algolia data and adjusting front-end logic to rely on those dates rather than is_on_sale.

4. Edge Case Handling

  • Implemented logic to detect and clean up invalid or incomplete price data.
  • Cleared site caches to ensure new price data and display logic were reflected immediately.

Final Outcome

The product category pages now correctly display variable product price ranges and sale prices, fully in sync with WooCommerce data. Additionally:

  • Algolia product data now includes min/max prices and sale price data.
  • Edge case display issues (zero prices, price formatting) have been resolved.
  • A documented bulk update process is available for future syncs.

Need help resolving WooCommerce, Algolia, or complex WordPress issues?
Freshy specializes in WordPress development, optimization, and support.
Contact us today for expert help