WHMCS guide

Find the promo codes that make orders free.

A test code at 100% that nobody deleted keeps working for anyone who finds it, and a recurring one takes every renewal too. On one of our own installs the first query below found a 100% recurring code with no use limit and no end date, already used 4 times.

DMS.S2 — Before you start

Before you run anything.

Read only

Every query below is a SELECT. It changes nothing. Run it in phpMyAdmin or the mysql client, on a copy of the database if you have one.

A row is a lead, not a verdict

A partner, a staff account or a holiday offer can be free on purpose. Ask whoever created the code before you change it.

Expire it, do not delete it

Deleting a code removes the record of who used it. Set an expiration date or a use limit under Configuration > Promotions instead.

DMS.S3 — The queries

Three ways to find them.

100% codes anyone can still use

Percentage codes at 100% or more with no use limit and no end date in the past. A far-off end date counts as no limit.

SELECT id, code, recurring, recurfor, uses, expirationdate
FROM tblpromotions
WHERE type = 'Percentage' AND value >= 100 AND maxuses = 0
  AND (expirationdate IS NULL OR expirationdate < '1000-01-01' OR expirationdate >= CURDATE());

Lifetime discounts of 50% or more

Recurring with no end (recurfor = 0) means every renewal, for as long as the service lives.

SELECT id, code, value, uses, expirationdate
FROM tblpromotions
WHERE type = 'Percentage' AND recurring = 1 AND recurfor = 0 AND value >= 50
  AND maxuses = 0
  AND (expirationdate IS NULL OR expirationdate < '1000-01-01' OR expirationdate >= CURDATE());

Live services renewing at 0.00 because of a code

Shows whether a code has already cost you renewals. Expiring the code does not change these services; their price is stored on each one.

SELECT p.code, p.type, p.value, COUNT(*) AS live_services, SUM(h.amount = 0) AS renewing_at_zero
FROM tblhosting h
JOIN tblpromotions p ON p.id = h.promoid
WHERE h.domainstatus IN ('Active', 'Suspended')
GROUP BY p.id, p.code, p.type, p.value
HAVING renewing_at_zero > 0;

DMS.S4 — The addon

Or get the list inside the WHMCS admin.

Brasa Pricing Audit runs these checks and the ones SQL cannot do alone, like a fixed amount or price override code that covers the first payment, and e-mails admins when a new finding appears. It never changes a code or a price.

Brasa Pricing Audit screen in the WHMCS admin, with sample data

Brasa Pricing Audit

$39 per year

Finds the price and catalog setups that give away money or block a sale.

  • Billing cycle at 0.00 and no price row in a currency
  • Promo code with no limit that makes an order free
  • Free domain on a term whose first payment does not cover the registration
  • Visible item with every cycle off, automatic setup with no server, 56 checks in all
First run in 16 seconds, on sample data: the summary, then each finding with what to fix. Brasa Pricing Audit on the WHMCS Marketplace
Buy for $39

DMS.S5 — Questions

Closing a free code.

How do I stop a promo code without losing its history?

Edit it under Configuration > Promotions and set an expiration date of today or a maximum number of uses equal to the current uses. New orders stop accepting it and the record of past use stays.

Does expiring the code fix services that already renew at 0.00?

No. WHMCS stores the recurring amount on each service when the order is placed. Change the recurring amount on the service itself, and tell the client first if the discount was promised.

Why do fixed amount codes not show up here?

A fixed amount or price override is free only when it covers the price, which depends on the product, the cycle and the currency. Compare each one with the prices it applies to, or let Brasa Pricing Audit do that comparison.