campaigns: disable daily discount by default — test normal-price deals
The daily 40%-off coupon was being merged into every trucking/UCR/IFTA/OTC
send, but those discount sends were not actually being delivered (the
DKIM-broken window). Now that deliverability is fixed, re-test whether
normal-price offers convert before giving margin away.
New CAMPAIGN_ENABLE_COUPON env flag (default OFF) gates daily-coupon
minting in build_trucking_campaigns + the UCR/IFTA/OTC builders (which
import it as tc.COUPON_ENABLED). With it off, no code is minted and an
empty coupon_code is merged -> the campaign templates' existing
{{ if .Subscriber.Attribs.coupon_code }} guard falls through to the
normal-price {{ else }} branch and landing-page links carry no ?code=.
No template or DB changes; fully reversible (set CAMPAIGN_ENABLE_COUPON=1).
Verified: COUPON_ENABLED defaults False, coupon_attribs(None) -> empty,
lp_link drops ?code= when no coupon, all 4 builders compile.
This commit is contained in:
parent
a04ecf7df3
commit
eed5e4a258
4 changed files with 25 additions and 5 deletions
|
|
@ -224,11 +224,13 @@ def main() -> int:
|
||||||
_reset_cycle_if_new(conn, q, due)
|
_reset_cycle_if_new(conn, q, due)
|
||||||
|
|
||||||
coupon = None
|
coupon = None
|
||||||
if args.start_campaign and not args.preview and not args.dry_run:
|
if tc.COUPON_ENABLED and args.start_campaign and not args.preview and not args.dry_run:
|
||||||
try:
|
try:
|
||||||
coupon = tc.get_or_create_daily_coupon(conn, today)
|
coupon = tc.get_or_create_daily_coupon(conn, today)
|
||||||
except Exception as exc: # noqa: BLE001
|
except Exception as exc: # noqa: BLE001
|
||||||
LOG.warning("[ifta] coupon mint failed: %s (sending without)", exc)
|
LOG.warning("[ifta] coupon mint failed: %s (sending without)", exc)
|
||||||
|
elif not tc.COUPON_ENABLED:
|
||||||
|
LOG.info("[ifta] coupon disabled (CAMPAIGN_ENABLE_COUPON unset) — normal price")
|
||||||
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute(SELECT_SQL, [list(tc.BLOCKED_EMAIL_DOMAINS), touch_no, args.limit])
|
cur.execute(SELECT_SQL, [list(tc.BLOCKED_EMAIL_DOMAINS), touch_no, args.limit])
|
||||||
|
|
|
||||||
|
|
@ -82,11 +82,13 @@ def main() -> int:
|
||||||
|
|
||||||
conn = psycopg2.connect(tc.DB_URL)
|
conn = psycopg2.connect(tc.DB_URL)
|
||||||
coupon = None
|
coupon = None
|
||||||
if args.start_campaign and not args.preview and not args.dry_run:
|
if tc.COUPON_ENABLED and args.start_campaign and not args.preview and not args.dry_run:
|
||||||
try:
|
try:
|
||||||
coupon = tc.get_or_create_daily_coupon(conn, date.today())
|
coupon = tc.get_or_create_daily_coupon(conn, date.today())
|
||||||
except Exception as exc: # noqa: BLE001
|
except Exception as exc: # noqa: BLE001
|
||||||
LOG.warning("[otc] coupon mint failed: %s", exc)
|
LOG.warning("[otc] coupon mint failed: %s", exc)
|
||||||
|
elif not tc.COUPON_ENABLED:
|
||||||
|
LOG.info("[otc] coupon disabled (CAMPAIGN_ENABLE_COUPON unset) — normal price")
|
||||||
|
|
||||||
def attribs(r):
|
def attribs(r):
|
||||||
si = (r.get("state_inc") or "").strip()
|
si = (r.get("state_inc") or "").strip()
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,16 @@ def lp_slug_for(campaign_type: str, phy_state: str | None = None) -> str:
|
||||||
# checkout enforce expiry + the service-fee-only scope (pass-through government
|
# checkout enforce expiry + the service-fee-only scope (pass-through government
|
||||||
# fees are never discounted). The code + prices are merged into the email so the
|
# fees are never discounted). The code + prices are merged into the email so the
|
||||||
# recipient sees a real, expiring deal.
|
# recipient sees a real, expiring deal.
|
||||||
|
#
|
||||||
|
# DISCOUNT TOGGLE: the daily coupon is DISABLED by default (Jun 2026). The
|
||||||
|
# discount sends were not being delivered (DKIM-broken window), so we are
|
||||||
|
# re-testing whether normal-price offers convert now that deliverability is
|
||||||
|
# fixed. With the coupon off, no code is minted and an empty coupon_code is
|
||||||
|
# merged -- the campaign templates' `{{ if .Subscriber.Attribs.coupon_code }}`
|
||||||
|
# guard automatically falls through to the normal-price `{{ else }}` branch and
|
||||||
|
# the landing-page links carry no `?code=`. Set CAMPAIGN_ENABLE_COUPON=1 to
|
||||||
|
# bring the daily deal back. Reversible, no template or DB changes needed.
|
||||||
|
COUPON_ENABLED = os.getenv("CAMPAIGN_ENABLE_COUPON", "0") in ("1", "true", "yes")
|
||||||
COUPON_PCT = int(os.getenv("CAMPAIGN_COUPON_PCT", "40"))
|
COUPON_PCT = int(os.getenv("CAMPAIGN_COUPON_PCT", "40"))
|
||||||
# Eligible slugs = every discountable service a trucking campaign can link to.
|
# Eligible slugs = every discountable service a trucking campaign can link to.
|
||||||
# Pass-through-only slugs (boc3-filing $25 passthrough, etc.) are intentionally
|
# Pass-through-only slugs (boc3-filing $25 passthrough, etc.) are intentionally
|
||||||
|
|
@ -903,13 +913,17 @@ def run(send_date: date, dry_run: bool = False, preview: bool = False,
|
||||||
conn = psycopg2.connect(DB_URL)
|
conn = psycopg2.connect(DB_URL)
|
||||||
|
|
||||||
# Mint (or reuse) the same-day coupon for this send date so every campaign
|
# Mint (or reuse) the same-day coupon for this send date so every campaign
|
||||||
# in the run shares one expiring code. Preview/dry runs skip the write.
|
# in the run shares one expiring code. Preview/dry runs skip the write, and
|
||||||
|
# the daily deal is disabled by default (see COUPON_ENABLED) -- when off we
|
||||||
|
# send at normal price (empty coupon_code -> template's no-deal branch).
|
||||||
daily_coupon = None
|
daily_coupon = None
|
||||||
if not dry_run and not preview:
|
if COUPON_ENABLED and not dry_run and not preview:
|
||||||
try:
|
try:
|
||||||
daily_coupon = get_or_create_daily_coupon(conn, send_date)
|
daily_coupon = get_or_create_daily_coupon(conn, send_date)
|
||||||
except Exception as exc: # noqa: BLE001
|
except Exception as exc: # noqa: BLE001
|
||||||
LOG.warning("[coupon] could not mint daily coupon: %s (sending without)", exc)
|
LOG.warning("[coupon] could not mint daily coupon: %s (sending without)", exc)
|
||||||
|
elif not COUPON_ENABLED:
|
||||||
|
LOG.info("[coupon] disabled (CAMPAIGN_ENABLE_COUPON unset) — sending at normal price")
|
||||||
|
|
||||||
base_mcs150 = get_base_campaign(CAMPAIGN_MCS150_ID)
|
base_mcs150 = get_base_campaign(CAMPAIGN_MCS150_ID)
|
||||||
base_inactive = get_base_campaign(CAMPAIGN_INACTIVE_ID)
|
base_inactive = get_base_campaign(CAMPAIGN_INACTIVE_ID)
|
||||||
|
|
|
||||||
|
|
@ -170,11 +170,13 @@ def main() -> int:
|
||||||
_reset_cycle_if_new(conn, year)
|
_reset_cycle_if_new(conn, year)
|
||||||
|
|
||||||
coupon = None
|
coupon = None
|
||||||
if args.start_campaign and not args.preview and not args.dry_run:
|
if tc.COUPON_ENABLED and args.start_campaign and not args.preview and not args.dry_run:
|
||||||
try:
|
try:
|
||||||
coupon = tc.get_or_create_daily_coupon(conn, today)
|
coupon = tc.get_or_create_daily_coupon(conn, today)
|
||||||
except Exception as exc: # noqa: BLE001
|
except Exception as exc: # noqa: BLE001
|
||||||
LOG.warning("[ucr] coupon mint failed: %s", exc)
|
LOG.warning("[ucr] coupon mint failed: %s", exc)
|
||||||
|
elif not tc.COUPON_ENABLED:
|
||||||
|
LOG.info("[ucr] coupon disabled (CAMPAIGN_ENABLE_COUPON unset) — normal price")
|
||||||
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute(SELECT_SQL, [list(tc.BLOCKED_EMAIL_DOMAINS), touch_no, args.limit])
|
cur.execute(SELECT_SQL, [list(tc.BLOCKED_EMAIL_DOMAINS), touch_no, args.limit])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue