Fix cart icon vanishing on add-to-cart when fragment fetch fails
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m4s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m4s
When the cart-mini fragment fetch returns empty, the HTMX outerHTML swap was replacing #cart-mini with nothing. Now falls back to the local _mini.html macro with count from g.cart. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,13 @@
|
|||||||
{# HTMX response after add-to-cart: OOB-swap the mini cart + product buttons #}
|
{# HTMX response after add-to-cart: OOB-swap the mini cart + product buttons #}
|
||||||
{% import '_types/product/_cart.html' as _cart %}
|
{% import '_types/product/_cart.html' as _cart %}
|
||||||
|
|
||||||
{# 1. Update mini cart via cart-mini fragment #}
|
{# 1. Update mini cart via cart-mini fragment (fallback to local macro) #}
|
||||||
{{ cart_mini_html | safe }}
|
{% 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 %}
|
||||||
|
|
||||||
{# 2. Update add/remove buttons on the product #}
|
{# 2. Update add/remove buttons on the product #}
|
||||||
{{ _cart.add(d.slug, cart, oob='true') }}
|
{{ _cart.add(d.slug, cart, oob='true') }}
|
||||||
|
|||||||
Reference in New Issue
Block a user