Auto-Remove Sale Price When Out of Stock WordPress Function

When an order moves to Processing or Completed, it scans the purchased items; if any SKU’s stock drops below 1, the function clears its sale price (and any sale schedule) and adds an order note.

19,99 

Request function

View Privacy Policy

Description

Auto-Remove Sale Price When Out of Stock WordPress Function

What it does?

  • Listens on key status changes – Runs when orders transition to Processing or Completed.

  • Checks each purchased item – Works with both simple products and variations.

  • Evaluates current stock – If the item’s stock is below 1, it removes the active sale price and any sale date range.

  • Audits the action – Adds an order note naming the product whose sale was removed, creating a clear trail for staff.

Why it’s useful?

  • Prevents misleading promos – Stops showing sale pricing on items that are no longer available, improving customer experience.

  • Protects margins – Avoids discounting scarce inventory that can’t ship right away.

  • Reduces manual work – Automates price hygiene after fulfillment steps, so staff don’t have to chase outdated promos.

  • Keeps storefront accurate – Ensures pricing reflects real availability during high-turnover periods.