Add ticket-to-cart integration
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m6s

Tickets now appear as cart line items, are included in checkout totals,
confirmed on payment, and displayed on the checkout return page.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-19 21:32:42 +00:00
parent b3efed2f60
commit cd41b6c8ef
11 changed files with 170 additions and 32 deletions

12
app.py
View File

@@ -21,10 +21,13 @@ from bp.cart.services import (
total,
get_calendar_cart_entries,
calendar_total,
get_ticket_cart_entries,
ticket_total,
)
from bp.cart.services.page_cart import (
get_cart_for_page,
get_calendar_entries_for_page,
get_tickets_for_page,
)
@@ -53,27 +56,32 @@ async def cart_context() -> dict:
# Cart app owns cart data — use g.cart from _load_cart
all_cart = getattr(g, "cart", None) or []
all_cal = await get_calendar_cart_entries(g.s)
all_tickets = await get_ticket_cart_entries(g.s)
# Global counts for cart-mini (always global)
cart_qty = sum(ci.quantity for ci in all_cart) if all_cart else 0
ctx["cart_count"] = cart_qty + len(all_cal)
ctx["cart_total"] = (total(all_cart) or 0) + (calendar_total(all_cal) or 0)
ctx["cart_count"] = cart_qty + len(all_cal) + len(all_tickets)
ctx["cart_total"] = (total(all_cart) or 0) + (calendar_total(all_cal) or 0) + (ticket_total(all_tickets) or 0)
# Page-scoped data when viewing a page cart
page_post = getattr(g, "page_post", None)
if page_post:
page_cart = await get_cart_for_page(g.s, page_post.id)
page_cal = await get_calendar_entries_for_page(g.s, page_post.id)
page_tickets = await get_tickets_for_page(g.s, page_post.id)
ctx["cart"] = page_cart
ctx["calendar_cart_entries"] = page_cal
ctx["ticket_cart_entries"] = page_tickets
ctx["page_post"] = page_post
ctx["page_config"] = getattr(g, "page_config", None)
else:
ctx["cart"] = all_cart
ctx["calendar_cart_entries"] = all_cal
ctx["ticket_cart_entries"] = all_tickets
ctx["total"] = total
ctx["calendar_total"] = calendar_total
ctx["ticket_total"] = ticket_total
ctx["menu_items"] = await get_navigation_tree(g.s)