Skip worker intake emails for batch orders, remove payment step for paid orders
- Batch orders: checkout API already sends combined intake email, so worker handlers no longer send their own (was causing 2-3 duplicate emails) - When accessed via ?token= or ?order= (post-payment), the "payment" step is removed from the intake wizard since payment is already complete Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
99bdfdfd91
commit
0d07b6a2d9
2 changed files with 20 additions and 25 deletions
|
|
@ -234,31 +234,16 @@ class BaseServiceHandler(ABC):
|
|||
except Exception as exc:
|
||||
logger.warning("Could not update order status: %s", exc)
|
||||
|
||||
# For batch orders, only the first order (lowest order_number) sends the
|
||||
# intake email. Others just pause silently. This avoids the race condition
|
||||
# where concurrent handlers all check DB before any has committed.
|
||||
if batch_id and customer_email:
|
||||
try:
|
||||
conn2 = psycopg2.connect(os.environ.get("DATABASE_URL", ""))
|
||||
cur2 = conn2.cursor()
|
||||
cur2.execute(
|
||||
"""SELECT MIN(order_number) FROM compliance_orders
|
||||
WHERE batch_id = %s""",
|
||||
(batch_id,),
|
||||
)
|
||||
first_order = cur2.fetchone()[0]
|
||||
cur2.close()
|
||||
conn2.close()
|
||||
if first_order and order_number != first_order:
|
||||
logger.info(
|
||||
"Skipping intake email for %s — batch %s will send from %s",
|
||||
order_number, batch_id, first_order,
|
||||
)
|
||||
return
|
||||
except Exception:
|
||||
pass # If check fails, send the email anyway
|
||||
# For batch orders, the checkout API already sends a combined intake
|
||||
# email (sendComplianceIntakeEmail). Workers should NOT send their own.
|
||||
if batch_id:
|
||||
logger.info(
|
||||
"Skipping worker intake email for %s — batch %s intake email sent by checkout API",
|
||||
order_number, batch_id,
|
||||
)
|
||||
return
|
||||
|
||||
# Email the client
|
||||
# Email the client (single/standalone orders only)
|
||||
if customer_email:
|
||||
try:
|
||||
import PyJWT as pyjwt
|
||||
|
|
|
|||
|
|
@ -319,8 +319,18 @@ const STEP_LABELS: Record<string, string> = {
|
|||
};
|
||||
|
||||
// ── Pre-fill from order data when accessed via token (paid batch order) ──
|
||||
// Also remove the "payment" step since payment is already done.
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
if (urlParams.has("token") || urlParams.has("order")) {
|
||||
const payIdx = steps.indexOf("payment");
|
||||
if (payIdx >= 0) {
|
||||
steps.splice(payIdx, 1);
|
||||
rebuildStepBar();
|
||||
}
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const params = urlParams;
|
||||
const token = params.get("token");
|
||||
const frn = params.get("frn");
|
||||
if (!token) return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue