Fix cart count: query DB directly instead of cross-app API
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 42s

Two bugs fixed:

1. First htmx add didn't update mini cart count because the context
   processor's API call couldn't see the uncommitted transaction.
   Fix: pass cart_count/cart_total explicitly from the route handler.

2. Page refresh always showed cart count 0 because the internal API
   call to the cart service failed to resolve cart identity correctly.
   Fix: replace the API call with a direct DB query using the same
   shared database and session, matching how the cart app itself works.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-15 10:39:43 +00:00
parent faa72eec5d
commit 28938e38b5
2 changed files with 23 additions and 9 deletions

View File

@@ -251,6 +251,8 @@ def register():
cart=g.cart,
item=ci,
total=total,
cart_count=sum(i.quantity for i in g.cart),
cart_total=total(g.cart),
calendar_total=lambda entries: 0,
calendar_cart_entries=[],
)