Render cart-mini directly in add-to-cart HTMX response
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 59s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 59s
The handler already has g.cart with the updated items — no need to make an HTTP round-trip to the cart app's fragment endpoint. Renders the _mini.html macro directly with the count from g.cart. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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') }}
|
||||
|
||||
Reference in New Issue
Block a user