Spaces:
Running
Running
Update main.py
Browse files1780 unmodified lines178117821783178417851786178717881789179033 unmodified lines18241825182618271828182919 unmodified lines1849185018511852185318541780 unmodified linesreceipt = sale_data.get("receipt_number", "N/A")total = float(sale_data.get("total_amount", 0))subtotal = float(sale_data.get("subtotal", total)) # if not stored, we can compute from itemsdelivery_fee = float(sale_data.get("delivery_fee", 0))handling_fee = float(sale_data.get("handling_fee", 0))# If items not provided, fetch themif items is None:client = get_supabase()33 unmodified lines</table>"""tracking_link = f"{PRODUCTION_HOST}/kdstore?receipt_number={receipt}&email={customer_email}"# --- Build the order summary (with fees broken out) ---19 unmodified lines<h3>Order Summary</h3>{summary_html}<hr><p>You can track your order anytime using this link:<br><a href="{tracking_link}">{tracking_link}</a></p><p>We'll notify you when it's shipped.</p>1780 unmodified lines1781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180933 unmodified lines184318441845184618471848184919 unmodified lines18691870187118721873187418751780 unmodified linesreceipt = sale_data.get("receipt_number", "N/A")total = float(sale_data.get("total_amount", 0))subtotal = float(sale_data.get("subtotal", total))delivery_fee = float(sale_data.get("delivery_fee", 0))handling_fee = float(sale_data.get("handling_fee", 0))# ---- Get customer phone (with fallback to profile) ----customer_phone = sale_data.get("customer_phone")if not customer_phone and sale_data.get("user_id"):client = get_supabase()try:profile = await run_sync_db_call(client.table("profiles").select("phone").eq("id", sale_data["user_id"]).maybe_single().execute)if profile and profile.data:customer_phone = profile.data.get("phone")except Exception as e:logger.warning(f"Could not fetch profile phone: {e}")if not customer_phone:customer_phone = "Not provided"# If items not provided, fetch themif items is None:client = get_supabase()33 unmodified lines</table>"""# ---- Correct tracking link (points to the store page where the modal lives) ----tracking_link = f"{PRODUCTION_HOST}/kdstore?receipt_number={receipt}&email={customer_email}"# --- Build the order summary (with fees broken out) ---19 unmodified lines<h3>Order Summary</h3>{summary_html}<hr><p><strong>Customer Phone:</strong> {customer_phone}</p> <!-- ADDED --><p>You can track your order anytime using this link:<br><a href="{tracking_link}">{tracking_link}</a></p><p>We'll notify you when it's shipped.</p>
main.py+22-1