Sale Price Overlays
The Middleware Platform supports a sale-price overlay feature that lets you define temporary discounted prices per SKU. These are applied on top of the live nFusion spot price before syncing to WooCommerce or Algolia.
How It Works
When a tenant has supports_markup_sale_prices = true:
NFusionService::getPrices()loads all on-sale products from theproductstable (seeProduct::getOnSaleProducts()).- For each product, if
markup_sale_priceis set and> 0, asale_askprice is calculated:
sale_ask = base_ask + (markup_sale_price × weight_in_ounces)
NFusionService::transformTiers()applies that sale price to retail tiers and returns both regular and sale-aware tier values.- The transformed tier prices plus
sale_starts_atandsale_ends_atare passed to sync providers. - WooCommerce sync writes
_sale_price,_sale_price_dates_from, and_sale_price_dates_tometa.
Managing Sale Prices
Sale prices are managed via the Products resource in the Filament admin panel.
| Field | Description |
|---|---|
sku | Product SKU (must match nFusion and WooCommerce) |
markup_sale_price | Per-ounce markup reduction (a lower number = cheaper sale price) |
sale_starts_at | When the WooCommerce sale should activate |
sale_ends_at | When the WooCommerce sale should deactivate |
Base Sale Price Formula
base_ask = nFusion BaseAsk (spot price + base markup, before retail tier markups)
weight = product weight in troy ounces
markup_sale = markup_sale_price from products table
sale_ask = base_ask + (markup_sale × weight)
If markup_sale is lower than the standard markup, the sale price will be lower than the regular price.
Tier Sale Price Logic (transformTiers())
transformTiers() now includes sale-aware tier pricing for retail tiers when all of these are true:
isOnSale === true(sale window is active)saleAskPrice > 0askPrice,baseAskPrice, andtier['Ask']are available
For each tier:
tier_delta = tier_ask - ask_price
sale_tier_ask = sale_ask + tier_delta
# Clamp to stay within valid bounds
sale_tier_ask = max(base_ask, min(ask_price, sale_tier_ask))
This preserves the tier discount/spread from the regular price while preventing invalid sale values.
Each transformed tier includes:
ask- effective price used by sync (sale tier price when on sale; regular tier price otherwise)ask_regular- regular tier price (set only in sale mode)ask_sale- computed sale tier price (set only in sale mode)markup-tier_ask - base_askqty- tier quantity break
If no tier data is provided, transformTiers() returns null.
WooCommerce Sync Integration
When syncing to WooCommerce:
_regular_priceremains the regular price_sale_priceis set tosale_ask_sale_price_dates_fromis set tosale_starts_at(Unix timestamp)_sale_price_dates_tois set tosale_ends_at(Unix timestamp)- tier pricing receives sale-aware
ask,ask_regular, andask_salevalues fromtransformTiers()
WooCommerce uses these dates to automatically activate and deactivate the sale price on the storefront.
Scope Notes
- Sale tier transforms are applied to retail tiers.
- Wholesale tiers are transformed without sale overlay parameters.
- If
supports_markup_sale_pricesis disabled for a tenant, normal non-sale tier pricing is used.
Populating the Products Table
Products are inserted or updated in the products table by the WooCommerce product-update webhook. When WooCommerce sends a product.updated event, WooCommerceProductUpdateController creates or updates a Product record.
See WooCommerce Product Update Webhook → for details.