Routing rule (READ FIRST). This recipe is a sub-step of Goal: Clear Inventory. If you arrived here directly from the WixREADME index, load the goal recipe NOW before executing — it owns the velocity scoring, classification cues, and the per-recommendation presentation rules (including the margin-floor guardrail surfacing requirement).
Then read Create Discount Rule with ReadFullDocsArticle — it contains the discount-rule mechanics and the pre-create guardrails (conflict/stacking, margin floor, %-sanity).
Creates a discount targeting slow-moving inventory — products with high stock levels and low sales velocity. The discount depth is proportional to how overstocked the product is, with deeper discounts for the most stagnant items. Margin protection guardrails are especially important here since clearance discounts tend to push closer to cost.
siteData.hasCatalog === true, checked at context load)Catalog analytics and product data are already in conversation context — do NOT re-fetch:
siteData.catalogAnalytics — category groups with sum(quantity), sum(ordersCount), avg(profitMargin). Loaded by the eCommerce Load Context.siteData.productCatalogData — per-product list sorted quantity DESC, ordersCount ASC for STOCK_MOVER goal. Loaded by the run-a-sale orchestrator Step 5.Extract from context:
total_quantity — sum(quantity) from the "All Products" group in siteData.catalogAnalyticstotal_orders — sum(ordersCount) from the "All Products" groupavg_profit_margin — sets the discount ceilingquantity, ordersCount, price, name, id, categoryId — from siteData.productCatalogDataCalculate the velocity ratio for each product to identify overstocked items:
| Velocity Ratio | Classification | Action |
|---|---|---|
| < 0.1 | Severely overstocked — fewer than 1 sale per 10 units in stock | High priority for clearance discount |
| 0.1 - 0.3 | Moderately overstocked — slow but not stagnant | Medium priority |
| 0.3 - 0.7 | Balanced — reasonable sell-through rate | Not a clearance candidate |
| > 0.7 | Fast-moving — selling well relative to stock | Do NOT discount — unnecessary margin erosion |
Select products with velocity_ratio < 0.3 as clearance candidates.
If quantity = 0 for a product, skip it (nothing to clear). If ordersCount = 0, the velocity ratio is 0 — this is the most urgent clearance case.
Scale the discount based on inventory urgency. Deeper discounts for more overstocked items, constrained by margin:
| Velocity Ratio | Recommended Discount | Rationale |
|---|---|---|
| 0 (zero sales) | 20-25% | Maximum urgency — product is not moving at all |
| < 0.1 | 15-20% | Severely slow — needs aggressive pricing |
| 0.1 - 0.2 | 10-15% | Moderately slow — moderate discount |
| 0.2 - 0.3 | 5-10% | Slightly slow — gentle nudge |
Margin constraint: Always verify discount <= avg_profit_margin - 15% (minMarginPct). Clearance discounts are more likely to violate margin thresholds because they are deliberately deeper.
Global cap: Do not exceed 25% unless the merchant explicitly overrides. For clearance, merchants may accept deeper discounts to free up capital and shelf space.
Select the scope based on the distribution of slow movers:
When selecting ITEMS scope, prioritize the products with the worst velocity ratios (lowest first), up to the max of 5 productIds.
If scope is CATEGORY, call getCategoryIds to convert category names to GUIDs.
Run the pre-create guardrails in Create Discount Rule → "Guardrails" before creating the rule (conflict/stacking, %-sanity, margin floor). Clearance is the most margin-sensitive case: discounts push closest to cost, so the margin-floor check (effective margin ≥ 15% unless the merchant overrides) is the one most likely to fire here — verify it per candidate product.
Endpoint: POST https://www.wixapis.com/ecom/v1/discount-rules
Request — 20% off specific slow-moving products:
Response:
Request — clearance on an entire category:
Save the returned id and revision for later management.
active: true"Clearance discount is live: {discount}% off {number_of_products} slow-moving items. These products had a velocity ratio of {avg_velocity}, indicating high stock relative to sales. Margin floor enforced — effective margin stays ≥ 15% on every targeted SKU. Monitor inventory levels — once stock clears, consider deactivating the rule."
When generating recommendations for the merchant (whether persisted as PROPOSED via the tracking API or returned inline), every clearance recommendation MUST include explicit margin-floor language in its reasoning / why field. Examples:
{product} below the 15% floor."Urgency labels, stock level, capital tied up, and the "Why {N}%" velocity rationale are NOT substitutes — the merchant must see a per-item margin protection statement on every clearance line. If you cannot meet the floor at the velocity-tier discount, either reduce the discount or drop the item; never silently breach the floor.
| Merchant intent | Scope | Discount depth | Notes |
|---|---|---|---|
| "Clear out old inventory" | ITEMS — top 5 slowest movers | Velocity-based (15-25%) | Target worst performers |
| "Clearance sale on winter items" | COLLECTION with category GUID | 15-20% | Category-wide clearance |
| "Get rid of product X" (specific) | SPECIFIC_PRODUCTS with product UUID | 20-25% (user may override) | Single product clearance |
| "Move stale stock across the store" | ITEMS — 5 worst velocity products | Velocity-based | Avoid SITE scope for clearance |
| "25% off these 3 items" (explicit) | SPECIFIC_PRODUCTS | 25% (user override) | Honor explicit request |
| Error | Cause | Fix |
|---|---|---|
DISCOUNT_RULE_NOT_FOUND | Rule ID doesn't exist | Re-query discount rules for current IDs |
REVISION_MISMATCH | Revision doesn't match | Re-fetch rule for latest revision, then retry |
| No slow movers found | All products have healthy velocity ratios (> 0.3) | Inform merchant that inventory is balanced; no clearance needed |
| Margin violation | Discount would push margin below 15% | Reduce discount percentage or get explicit merchant override |
| Quantity data missing | Products lack inventory tracking | Cannot identify slow movers; ask merchant to enable inventory tracking or specify products manually |
| Max items exceeded | More than 5 slow-moving products identified | Select the 5 with worst velocity ratios; consider CATEGORY scope if they share a category |
Last updated: 25 June 2026