Skip to main content

Algolia Product Pricing

The Dealers Site uses Algolia as its search and product-browse engine. Product prices are stored in the Algolia index and updated in near-real time by the Middleware Platform's pricing sync. Prices are calculated by the SDM Middleware using nFusion data, then synced to Algolia, ensuring dealers always see current pricing in search results without requiring a WooCommerce page refresh.


Architecture

nFusion API → Middleware (PriceSyncService — calculates prices)

POST /suma/v1/prices (import to dealer site)

WooCommerce Product Meta (_price, _markup_rate, _volume_pricing)

AlgoliaSyncTargetProvider (reads calculated prices from meta)

Algolia Search Index (dealer_products)

WP Search with Algolia plugin

InstantSearch.js (frontend)

Dealer browser — live pricing displayed

How Prices Get Into Algolia

  1. The SDM Middleware fetches nFusion data (ask prices, volume tiers, spot prices, markups) every 5 minutes.
  2. The PriceSyncService calculates final dealer prices (spot + markup + adjustments) and generates volume tier breakpoints.
  3. Calculated prices are imported into the Dealer Site via POST /suma/v1/prices, storing them in WooCommerce product meta.
  4. The AlgoliaSyncTargetProvider reads the calculated prices from product meta and syncs them to Algolia object attributes.
  5. Algolia object records are updated via partialUpdateObjects — only price fields change; product content (descriptions, images, SKU, etc.) remains untouched.
  6. The Dealers Site's InstantSearch.js frontend reads prices directly from the Algolia hit attributes — no WooCommerce page request needed.

Algolia Index

The Dealers Site uses a dedicated Algolia index (separate from the Retail site's index). The index name and credentials are configured in wp-config.php:

define( 'ALGOLIA_APP_ID',    'XXXXXXXXXX' );
define( 'ALGOLIA_API_KEY', 'xxxxxxxx...' ); // Search-only key (frontend)

Admin operations (indexing, price updates) use the Admin API key, which is stored securely in the Middleware Platform's .env.


Algolia Object Attributes (Pricing)

After a sync run, each product object in Algolia contains:

AttributeDescription
skuProduct SKU
regular_priceStandard ask price (from nFusion ask field)
retail_tiersVolume pricing tiers (array of {qty, ask, markup})
cc_priceCredit card price (if payment adjustment configured)
wire_priceWire transfer price (if payment adjustment configured)
sale_priceTemporary discounted price (if sale overlay active)

WP Search with Algolia Plugin

The WP Search with Algolia plugin (plugins/wp-search-with-algolia/) provides:

  • Index management UI in WP admin
  • WordPress search integration (redirects searches to Algolia)
  • WooCommerce product indexing hooks

The theme's class-algolia.php and class-algolia-custom-search.php extend the plugin's index classes to customise which post types and attributes are indexed.


Pricing Catalog Override

Dealers can be assigned a pricing catalog (stored as user meta pricing_catalog). When a pricing catalog is assigned:

  1. The WooCommerce product/cart layer applies the catalog's markup overrides on top of the Algolia-sourced base price.
  2. Non-catalog dealers see the default prices from the Algolia index.

Pricing catalogs are managed via the custom REST endpoint GET/POST /suma/v1/pricing-catalogs.


Custom Algolia Search Extend

class-algolia-custom-search.php defines Algolia_Searchable_Posts_Index_Not_Products — a custom Algolia index class that indexes non-product posts (pages, posts) while excluding products (which have their own index). This ensures the site's content search returns relevant pages without clogging the product pricing index.