diff --git a/bp/product/routes.py b/bp/product/routes.py index ce17917..19e76c4 100644 --- a/bp/product/routes.py +++ b/bp/product/routes.py @@ -254,23 +254,8 @@ def register(): # htmx response: OOB-swap mini cart + product buttons if request.headers.get("HX-Request") == "true": - # Commit so the cart app sees the updated data when we fetch the fragment - await g.tx.commit() - g.tx = await g.s.begin() - - from shared.infrastructure.fragments import fetch_fragment - from shared.infrastructure.cart_identity import current_cart_identity as _ci - frag_ident = _ci() - cart_params = {} - if frag_ident["user_id"] is not None: - cart_params["user_id"] = frag_ident["user_id"] - if frag_ident["session_id"] is not None: - cart_params["session_id"] = frag_ident["session_id"] - cart_mini_html = await fetch_fragment("cart", "cart-mini", params=cart_params) - return await render_template( "_types/product/_added.html", - cart_mini_html=cart_mini_html, cart=g.cart, item=ci, ) diff --git a/templates/_types/product/_added.html b/templates/_types/product/_added.html index 3005e4e..21489aa 100644 --- a/templates/_types/product/_added.html +++ b/templates/_types/product/_added.html @@ -1,13 +1,9 @@ {# HTMX response after add-to-cart: OOB-swap the mini cart + product buttons #} {% import '_types/product/_cart.html' as _cart %} -{# 1. Update mini cart via cart-mini fragment (fallback to local macro) #} -{% if cart_mini_html %} - {{ cart_mini_html | safe }} -{% else %} - {% from '_types/cart/_mini.html' import mini with context %} - {{ mini(count=cart | sum(attribute="quantity")) }} -{% endif %} +{# 1. Update mini cart directly — handler already has the cart data #} +{% from '_types/cart/_mini.html' import mini with context %} +{{ mini(count=cart | sum(attribute="quantity")) }} {# 2. Update add/remove buttons on the product #} {{ _cart.add(d.slug, cart, oob='true') }}